datapunt_processing.transform.geospatial package

Submodules

datapunt_processing.transform.geospatial.addres_to_latlon_in_df module

datapunt_processing.transform.geospatial.addres_to_latlon_in_df.adress_to_latlon(df)

This function adds the lattitude and longtitude to a pandas df based on an adress.

input: pandas df met tenminste de volgende variabelen:

  • Straat: String met de naam van de straat
  • Huisnr: String met huisnummer

output: pandas df waaraan de volgende variabelen zijn toegevoegd:

  • lon: longtitude behorend bij adres
  • lat: lattitude behorend bij adres

datapunt_processing.transform.geospatial.api_clean_BAG_address_NED module

datapunt_processing.transform.geospatial.api_clean_BAG_address_NED.main()
datapunt_processing.transform.geospatial.api_clean_BAG_address_NED.parser()

Parser function to run arguments from commandline and to add description to sphinx docs. To see possible styling options: https://pythonhosted.org/an_example_pypi_project/sphinx.html

datapunt_processing.transform.geospatial.api_get_areacodes_from_latlon module

datapunt_processing.transform.geospatial.api_get_areacodes_from_latlon.getAreaCodes(item, lat, lon)
Get specific information like area codes based radius to nearest address based on lat/lon value
ex: https://api.data.amsterdam.nl/geosearch/search/?item=verblijfsobject&lat=52.3731750&lon=4.8924655&radius=50

It currently is coded to work to get: - “buurt” - “buurtcombinatie” - “stadsdeel”

datapunt_processing.transform.geospatial.api_get_areacodes_from_latlon.getAreaCodesforDataFrame(df, item)

Get specific information like area codes based radius to nearest address based on lat/lon value for each row in pandas DF. Args:

df with column “lon” and “lat” item, which is “buurt”, “buurtcombinatie” or “stadsdeel”
Returns:
df with two new columns that describe name and code of the item “
datapunt_processing.transform.geospatial.api_get_areacodes_from_latlon.getJson(url)

Get a json from an url

Args:

url: give an api url:

https://api.data.amsterdam.nl/bag/gebieden/stadsdeel
Returns:
a parsed json result or an error message

datapunt_processing.transform.geospatial.api_get_nearest_address_from_latlon module

datapunt_processing.transform.geospatial.api_get_nearest_address_from_latlon.get_address_near_point(lat, lon, radius)

Get nearest addres and housenumber based on location.

get_address_near_point(52.3729378, 4.8937806, 50)

Args:
  1. lat: 52.3729378
  2. lon: 4.8937806
  3. radius: 50
Returns:
Dictionary of the first found address with openbareruimte, huisnummer, postcode, etc…
datapunt_processing.transform.geospatial.api_get_nearest_address_from_latlon.get_openbareruimte(lat, lon)

Get the name the street location where it coordinate resides on.

Args:
  1. lat: 52.3729378
  2. lon: 4.8937806
Result:
Returns dictionary of the openbare ruimte object

datapunt_processing.transform.geospatial.csv_get_centroid_of_street module

datapunt_processing.transform.geospatial.csv_get_centroid_of_street.get_centroid_street(filename, street_column, city_name)

Get the X,Y centroid of an address.

Args:
  1. street_column: Dam 1
  2. city_name: Amsterdam
Returns:
Origional CSV file with coordinates and BAG corrected naming.
datapunt_processing.transform.geospatial.csv_get_centroid_of_street.main()
datapunt_processing.transform.geospatial.csv_get_centroid_of_street.parser()

datapunt_processing.transform.geospatial.divide_bbox_amsterdam_in_quadrants module

datapunt_processing.transform.geospatial.divide_bbox_amsterdam_in_quadrants.calculation(number_of_boxes, bbox)

Divide the BBOX of the City of Amsterdam in x number of quadrants/rectangles for use in limiting WFS/geo queries.

Args:
  1. number_of_boxes: in multiples of 2, 8 works well for most cases.
  2. bbox: [110200,476772,134030,493900]
Returns:
list of quadrants [[x1,y1,x2,y2],[..]]

datapunt_processing.transform.geospatial.geocode_xls_to_csv module

datapunt_processing.transform.geospatial.geocode_xls_to_csv.main()
datapunt_processing.transform.geospatial.geocode_xls_to_csv.parser()

Parser function to run arguments from commandline and to add description to sphinx docs. To see possible styling options: https://pythonhosted.org/an_example_pypi_project/sphinx.html

datapunt_processing.transform.geospatial.get_area_wfs_by_point module

datapunt_processing.transform.geospatial.get_area_wfs_by_point.getPointInPolygon(wfs_url, layer_name, epsg, output_format, xy)

Function to generate an url like this: ‘’https://map.data.amsterdam.nl/maps/gebieden?request=getfeature&typename=gebiedsgerichtwerkenpraktijkgebieden&service=wfs&version=2.0.0&filter=<ogc:Filter><ogc:Contains><ogc:PropertyName>Request</ogc:PropertyName><gml:Point srsName=”urn:x-ogc:def:crs:EPSG:28992”><gml:pos srsName=”urn:x-ogc:def:crs:EPSG:28992”>121343.00,487441.00</gml:pos></gml:Point></ogc:Contains></ogc:Filter>’‘

Args:

  • wfs_url: main url of wfs, for example: https://map.data.amsterdam.nl/maps/gebieden
  • layer_name: name of layer, for example gebiedsgerichtwerkenpraktijkgebieden
  • output_format: geojson, txt, shapezip, json
  • epsg: 28992 or 4326
  • xy: X_RD,Y_RD with no spaces, for example: 121343.00,487441.00 or 52.3738107,4.8929629
Results:
json with the data
datapunt_processing.transform.geospatial.get_area_wfs_by_point.getWFSFeaturesWithinPolygonByID(wfsURL, layerName, GML, spid)

Example:

‘’https://map.data.amsterdam.nl/maps/bgtobjecten?REQUEST=GetFeature&SERVICE=wfs&Version=1.0.0&typeName=ms:BGT_BTRN_groenvoorziening&srsNAME=urn:ogc:def:crs:EPSG::4326&FILTER=<ogc:Filter><ogc:Within><gml:MultiPolygon srsName=”EPSG:4326”><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4.89566592,52.41515348 4.89574274,52.41519665 4.8957942,52.41520363 4.89585313,52.41519937 4.89590495,52.41517364 4.89595676,52.41514792 4.89618611,52.41504513 4.89635251,52.41497816 4.89669975,52.41486458 4.89685122,52.41481559 4.89727973,52.41467753 4.89761594,52.41456389 4.897823,52.41447905 4.89796369,52.41440521 4.89800256,52.41437784 4.898279,52.41418323 4.89846075,52.41405769 4.89855719,52.41399042 4.89858328,52.41396121 4.89858385,52.41390934 4.89855228,52.41388318 4.89834311,52.41370987 4.89814967,52.41356022 4.89801535,52.4134544 4.89761767,52.41313702 4.8974024,52.41296473 4.89668365,52.41239116 4.8964442,52.41220059 4.89599261,52.41184341 4.89575992,52.4116577 4.89558351,52.41150642 4.89546762,52.41147237 4.89539635,52.41147987 4.89493112,52.41170211 4.894841,52.41177971 4.89478877,52.41187939 4.89472055,52.41317238 4.89472698,52.41325585 4.89474481,52.41330779 4.89479185,52.41338016 4.89482653,52.4134396 4.89481866,52.41346708 4.89478415,52.4134918 4.89470032,52.41352547 4.89463595,52.41354221 4.89463128,52.41365456 4.89462594,52.41378302 4.89461958,52.41393576 4.89462659,52.41393939 4.89466149,52.41395746 4.89465453,52.4140708 4.89466117,52.41431945 4.89467052,52.41436099 4.89467987,52.41440253 4.89471689,52.41443461 4.89477448,52.41447689 4.89491769,52.41458203 4.89521691,52.41481783 4.89555275,52.41506957 4.89566592,52.41515348</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogc:Within></ogc:Filter>’‘

datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points module

datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.add_location_data(location)
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.cleanup_properties(location)
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.get_address_near_point(lat, lon, radius)

Get nearest addres and housenumber based on location.

get_address_near_point(52.3729378, 4.8937806, 50)

Args:
  1. lat: 52.3729378
  2. lon: 4.8937806
  3. radius: 50
Returns:
Dictionary of the first found address with openbareruimte, huisnummer, postcode, etc…
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.get_elements(div_content, element_type)
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.get_filename(url)
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.get_location_information(uri)

Get html page, find the header and values by h4 and p and return as a list with 2 values

datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.get_pand(lat, lon, radius)

Get the name the street location where it coordinate resides on.

Args:
  1. lat: 52.3729378
  2. lon: 4.8937806
Result:
Returns dictionary of the pand object
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.main()
datapunt_processing.transform.geospatial.get_bag_address_from_geojson_points.remove_html_elements(text)

datapunt_processing.transform.geospatial.postgres_add_areas_from_coordinates module

datapunt_processing.transform.geospatial.postgres_add_areas_from_coordinates.executeScriptsFromFile(pg_str, filename)

WIP does not work yet

datapunt_processing.transform.geospatial.postgres_add_areas_from_coordinates.main()
datapunt_processing.transform.geospatial.postgres_add_areas_from_coordinates.parser()

datapunt_processing.transform.geospatial.rd_to_wgs84 module

datapunt_processing.transform.geospatial.rd_to_wgs84.rd_to_wgs84(X, Y)

Quick reprojection method, does result in 1m max offset difference. Use Postgres ST_Transform method if you want a better reprojection. Example downloaded from http://forum.geocaching.nl/index.php?showtopic=7886

Module contents