ua-snap / geospatial-vector-veracity

Veracious geospatial vector data for use in SNAP tools.
MIT License
2 stars 0 forks source link

Track polygon attributes as vanilla JSON #32

Open charparr opened 2 years ago

charparr commented 2 years ago

Strip the geometry and export the shape file or GeoJSON to a straight JSON where the index (the id like "NPS7") is the top level. Doing this will facilitate dropping these names into tools for dropdown selections, search results, etc.

import geopandas as gpd
import pandas as pd

df = gpd.read_file("ak_protected_areas.shp")
x = df.copy()
del x['geometry']
z = pd.DataFrame(x)
z.T.to_json("ak_protected_areas_no_geometry.json")```

to generate a JSON like:

  {
    "id": 19070506,
    "name": "Charley River-Yukon River",
    "alt_name": "",
    "type": "huc"
  },