iwfm.gisΒΆ

Classes, methods and functions to read, write and modify gis files for IWFM and IGSM files.

Modules

bearing(p1, p2)

Return the bearing between two (lat,lon) points p1 = [lat1,lon1], p2 = [lat2,lon2] in degrees Description of algorithm at https://www.mathsisfun.com/sine-cosine-tangent.html.

choropleth(infile, fieldname1, fieldname2[, ...])

Read a shapefile and write a choropleth image.

contour2png(source, target[, iwidth, iheight])

Draw an entire contour shapefile to a PNG image.

dd2dms(lat, lon)

Convert lat-lon point from decimal degrees to degree-minute-second.

density_plot(infile, fieldname[, iwidth, ...])

Read a shapefile and write it as an image.

distance_ellipse(p1, p2[, units])

Use the Vincenty formula to calculate the distance between two (lat,lon) points on an ellipsoid Earth.

distance_sphere(p1, p2[, units])

Use the Haversine formula to calculate the distance between two (lat,lon) points on a sphere.

dms2dd(lat, lon)

Convert from degree-minute-second to decimal degrees.

elem2boundingpoly(elem_nodes, node_coords[, ...])

Create a shapely Polygon of the boundary of an IWFM model.

elem2shp(elem_ids, elem_nodes, ...[, epsg, ...])

Create an IWFM element shapefile.

elem_zbud2shp

Read IWFM Elemental Z-Budget output file and place the sum of each column into a copy of the elemental hapefile.

elems2shp_csv(elem_nodes, node_coord_dict[, ...])

Create a shapefile of the elements with the element ids and node ids.

geocode(address[, verbose])

Return the lat-lon of a street address.

geocode_ex(address[, verbose])

Example: Find the lat-lon of a street address and then reverse to use the lat-lon to get the address information.

geocode_json(address[, verbose])

Return the lat-lon of a street address as a GeoJSON FeatureCollection.

geocode_mp(cities)

Use multiprocessing to find and return multiple geocodes.

geocode_wkt(address[, verbose])

Return the lat-lon of a street address in WKT format.

geojson2shp(geojs)

Create a point shape from a geojson object.

geop_open(infile)

Open a file with geopandas and return geopandas object.

geop_plot(gdf, **kwargs)

Create and dislay a plot from a geopandas dataframe.

geop_saveplot(gdf, outname, **kwargs)

Create and save plot from geopandas dataframe.

geopdf_create(filename)

Create a geopdf canvas that can be drawn on.

geopdf_draw_rect_ex(canvas)

Example - draw a rectangle on the geopdf canvas.

getWKT_prj(epsg_code[, verbose])

Return a WKT string containing PRJ info for <epsg_code>.

get_boundary_coords(elem_nodes, node_coords)

Get (x,y) list for the nodes on the bounding polygon.

get_utm_zone(longitude)

Get the UTM zone for longitude.

gis

Typer subapp for IWFM GIS utilities.

grid2img(source, target)

Convert an ASCII DEM to an image.

grid_colorize(source, target)

Convert an ASCII DEM to an image and colorize using a heat-map color ramp.

grid_contour(source, target)

Use GDAL and OGR to create a contour shapefile.

grid_read(infile)

Read an ASCII Grid file.

grid_shadedrelief(source, slopegrid, ...[, ...])

Create a shaded relief ASCII grid from an ASCII DEM.

grid_write(outfile, array[, xllcorner, ...])

Write an ASCII Grid file.

heatmap(infile, outfile, title)

Read (x,y) points from a CSV file and create a heatmap overlaid on a web map.

hillshade(array, azimuth, angle_altitude)

Convert array to hillshade for a city Source: http://geoexamples.blogspot.com.br/2014/03/shaded-relief-images-using-gdal-python.html.

histogram(infile[, scl])

Generate and display the color histogram of an image.

histogram_array(arr[, bins])

Determine the histogram function for multi-dimensional array <arr>.

histogram_draw(hist[, scale])

Create an image from a histogram array.

igsm2shp(main_file, shape_name[, verbose])

Read the names of the preprocessor component input files, read the contents of these files, and create node, element, stream node and stream reach shapefiles.

igsm_elem2shp(elem_nodes, node_coords, ...)

Create an elements shapefile for an IGSM model.

image2Array(i)

Convert a Python Imaging Library array to a gdal_array.

img_2_array(img)

Convert a Python Imaging Library array to a gdal_array image.

img_classify(source, target)

Classify a remotely sensed image.

img_clip(raster, clipshape, outfile)

Clip a raster file to a shapefile clipping mask.

img_diff(img1, img2, outfile)

Perform a simple difference image change detection on matched 'before' and 'after' images.

img_extract(source, target)

Automatically extract features of a threshold image to a shapefile.

img_stretch(infile, outfile)

Stretch the color bands of an image.

img_swap_bands(infile, outfile[, band1, band2])

Read a TIFF file, swaps two bands, and saves it.

img_threshold(source, target)

Threshold an image to black and white.

is_northern(latitude)

Determine if given latitude is a northern for UTM.

iwfm2shp(main_file, shape_name[, epsg, verbose])

Take the IWFM model main preprocessor file name and a base name for output files, and create node, element, stream node and stream reach shapefiles.

json_read(jdata[, verbose])

Read a json file.

kml_points(filename[, verbose])

Get point coordinates from a KML file.

las2dem(source, target[, cell, NODATA])

Convert a LIDAR LAS file to an ASCII DEM.

las2shp(source, target[, max_edge_length, ...])

Convert an LAS LIDAR file to a shapefile by creating a 3D triangle mesh using Delaunay Triangulation.

latlon_2_utm(lat, lon)

Reproject from geographic coordinates to UTM.

make_prj(filename, epsg_code)

Make projection file <filename>.prj for epsg code <epsg_code>.

map_divs2shp(deliv_area_ids, deliv_areas, ...)

Add diversion areas to shapefile of IWFM model elements.

map_elempump(elempump_file_name, ...[, verbose])

Add diversion areas to shapefile of IWFM model elements.

map_elempump2shp(zone_data, field_names, ...)

Add diversion areas to shapefile of IWFM model elements.

map_lu(land_use_file, elem_shp_name, ...[, ...])

Copy IWFM model elements shapefile, and create one shapefile of total area for each year and element, and another shapefile with percent element area for each year and element.

map_param2shp_elems(param_types, param_vals, ...)

Read a shapefile of IWFM model elements and map an IWFM parameter to the elements.

map_param2shp_nodes(param_type, param_vals, ...)

Read a shapefile of IWFM model nodes and map an IWFM parameter to the nodes.

map_param2shp_rz(param_types, param_vals, ...)

Read a shapefile of IWFM model elements and map IWFM Rootzone Crop parameters to the elements.

map_param2shp_rz_natrip

Read a shapefile of IWFM model elements and map IWFM Rootzone Native and Riparian parameters to the elements.

map_param2shp_rz_npc(param_types, ...[, ...])

Read a shapefile of IWFM model elements and map IWFM Non-Ponded Crop parameters to the elements.

map_param2shp_rz_pc(param_types, param_vals, ...)

Read a shapefile of IWFM model elements and map IWFM Ponded Crop parameters to the elements.

map_param2shp_rz_urban(param_types, ...[, ...])

Read a shapefile of IWFM model elements and map IWFM Rootzone Urban parameters to the elements.

map_rchg2shp(div_ids, rchg_areas, ...[, verbose])

Add diversion recharge areas to shapefile of IWFM model elements.

method_fns(shpfilename, shpfile[, verbose])

Return the functions associated with the shpfile library.

mysql_commit(conn)

Commit changes to a mysql database.

mysql_conn(dbname[, port, host, user, passwd])

Connect to a mysql database.

mysql_create(dbname[, host, port, user, ...])

Create a mysql database DEMO - how to do it.

mysql_insert_record(cur, city, coord)

Insert a record into a mysql database.

mysql_new_table(cur, table_name)

Add a new table to a mysql database.

mysql_read(cur)

Read a mysql database.

nmea_parse(infile)

Read a GIS waypoint file and write lat-lon values.

nodal_multivalues2shp(node_coords, values, ...)

Create node shapefile for an IWFM model with multiple values for each node.

nodal_values2shp(node_coords, values, ...[, ...])

Create node shapefile for an IWFM model with a value for each node.

nodes2shp(node_coords, shape_name[, epsg, ...])

Create an IWFM nodes shapefile.

nodes2shp_csv(node_coord_dict[, shapename, ...])

Create a shapefile of the nodes with the node ids.

osmnx_getData(place)

Return streen network data for city <place>.

osmnx_street_len(city)

Use OSMNX to calculate average street length for a city.

point2geojson(point[, verbose])

Convert a point to geojson format.

point_in_poly(x, y, poly)

Is the point inside the polygon?

projection(shapename[, epsg, verbose])

Create projection files for shapefiles.

qgis_init([verbose])

Initialize the QGIS application.

qgis_init_paths([debug])

Initialize QGIS paths.

qgis_layer_names(project)

Get a list of QGIS project layer names and paths.

qgis_open_proj(filename[, verbose, debug])

Open a QGIS project.

qgis_print_geometry(geom)

Print QGIS geometry informatio to screen.

qgis_save_project(project[, name])

Save a QGIS project.

raster_band2jpeg(infile, band, outfile[, format])

Extract a raster band to a file.

raster_open(infile)

Open a raster file.

reach2shp(reach_list, stnodes_dict, ...[, ...])

Create an IWFM stream reaches shapefile from IWFM Preprocessor stream specification information.

shp2png(shape, outname[, iwidth, iheight])

Convert a shapefile to a raster and save as a png file - including white fill.

shp2png_empty(shape, outname[, iwidth, iheight])

Convert a shapefile to a raster and saves as a png file - just the outline with no fills.

shp2png_poly(shape, outfile[, iwidth, iheight])

Convert a shapefile to a raster and save as a PNG file, filling in polygon holes.

shp2wkt(shapefile)

Translate shapefile geometry info to WKT format.

shp_add_field(shapefilename[, field_name, ...])

Add a field to a shapefile with PyShp.

shp_area(polygon)

Return the geodesic area of a polygon in geographic (lon-lat) coordinates.

shp_bounds(f)

Return bounding box for PyShp shapefile.

shp_crs(filename)

Return the shapefile coordinate reference system from the sidecar .prj file.

shp_driver_type(filename[, verbose])

Return the driver.

shp_epsg(filename)

Read the projection file and returns the EPSG value.

shp_fieldnames(f)

Return the field names for PyShp shapefile.

shp_fields(f)

Return the field property strings for PyShp shapefile.

shp_fields_print(f)

Print the field property strings for a PyShp shapefile.

shp_geomtype(f)

Return shape geometry for PyShp shapefile.

shp_get(infile)

Read a shapefile with PyShp.

shp_get_OGR(infile[, verbose])

Open a shapefile with OGR.

shp_get_PyShp(infile[, verbose])

Read a shapefile with PyShp.

shp_get_writer(outfile, type)

Get a writer for a shapefile of the same type as the input shapefile.

shp_getcol(f, col)

Return one column from the shapefile table.

shp_getcol_lg(f, col)

Return one column from the shapefile table.

shp_getrec(f, i)

Return a shapefile record as a string.

shp_getrec_fn(f, i, field_name)

Return the item in the column specified by field_name for record i for a PyShp shapefile.

shp_getrec_lg(f, i)

Return a record as a string.

shp_getrow(inshape, rec)

Return one row or record for a shapefile opened with PyShp.

shp_getrow_lg(inshape, rec)

Return one row or record for a shapefile opened with PyShp, works better for large DBF files.

shp_norec(f)

Return the number of records in a shapefile.

shp_reproject(srcName, tgtName[, epsg])

Project a shapefile to another shapefile in <spatRef> coordinate system.

shp_to_utm_pts(shape, outfile[, verbose])

Reproject a point shapefile to UTM.

shp_type(shp)

Return integer shape type for a PyShp shapefile.

shp_type_txt(shp)

Return a standard text string of the shape type for a PyShp shapefile.

snodes2shp(nsnodes, snodes_list, ...[, ...])

Create an IWFM stream nodes shapefile.

stretch(a)

Perform a histogram stretch on a gdal_array array image.

utm_2_latlon(easting, northing, zone[, band])

Reproject from UTM to geographic coordinates.

utm_2_wgs84(zone, easting, northing)

Reproject from UTM to geographic coordinates.

wgs84_2_utm(lon, lat)

Reproject a WGS84 shapefile to UTM.

wk2_getBoundingBox(wkt)

Get WKT object bounding box.

wks2shp_pt(inwksheet, outshp[, sheet_index])

Read an Excel workbook and create a POINT shapefile.

wkt2poly(intxt)

Turn WKT text description into object.

world2pixel(geoMatrix, x, y)

Use a GDAL geomatrix to calculate the pixel location of a geospatial coordinate.

world2screen(bbox, w, h, x, y)

Convert geospatial coordinates to screen pixels.

xml_fix(infile, outfile[, verbose])

Read a broken XML file and write repaired file.

xml_tracks(filename[, verbose])

Reproject from UTM to geographic coordinates.