Skip to main content
47 votes
Accepted

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

To write to GeoJSON: dataframe.to_file("output.json", driver="GeoJSON") To write to GeoPackage: dataframe.to_file("output.gpkg", driver="GPKG") Documentation is here, though somewhat sparse.
toms's user avatar
  • 7,018
21 votes

Generating random coordinates in multipolygon in Python?

With Shapely: https://shapely.readthedocs.io/en/latest/manual.html#polygons The polygon in code below must be Polygon object. import random from shapely.geometry import Point def generate_random(...
dmh126's user avatar
  • 6,762
15 votes

Import unknown text polygon format to QGIS

Interesting. It is obviously not a CSV content, but a JSON. If you use the following script to convert the file content to a layer in QGIS Python Editor, you get a polygon as in the image. Edit: OK. ...
Kadir Şahbaz's user avatar
12 votes

Working with complex JSON attributes in QGIS

In recent QGIS versions (> 3.3), if you have a JSON field in a PostgreSQL database, you can use the map_get function anywhere with the Expression Dialog to extract a specific value. E.g if you have a ...
TheVRChris's user avatar
11 votes

Import unknown text polygon format to QGIS

First, the syntax of your data is JSON. But it's not the common GeoJSON representation, which would be easy to work with. It looks a bit like ESRI JSON, which uses "attributes" and "...
Cowirrie's user avatar
  • 705
10 votes

Convert GeoJSON polygon to point before rendering in Leaflet Map

You can use Turf.js to calculate the centroids of the polygons. Just include it in your HTML head. In my case, I am using the CDN: <script src="https://unpkg.com/@turf/[email protected]/turf.min.js">&...
BritishSteel's user avatar
  • 6,647
9 votes

Converting ArcGIS Server JSON to GeoJSON?

ArcGIS now supports GeoJSON Now ArcGIS Server (since 10.4) and ArcGIS Online has GeoJSON through ArcGIS Rest API URL. All you need to do is set f=geojson in the URL and configure the service. Be aware,...
hoogw's user avatar
  • 1,752
9 votes

QGIS does not show the Geometry Collection Polygons from JSON file

The file is not corrupt. QGIS does not support GeometryCollection as a valid geometry type. You will have to parse it. Here is a related answer. Something like this will get you to the data: with ...
gisdude's user avatar
  • 535
8 votes
Accepted

GeoJSON not displaying in QGIS

This JSON file is not a valid GeoJSON. It is a FeatureCollection with 56 Features, but 3251 geometries A valid GeoJSON Feature format is (with 1 geometry for 1 feature and the fundamental keys/tags '...
gene's user avatar
  • 55.1k
7 votes

GeoServer and PostgreSQL JSON column

For those wondering, at version 2.13.0, GeoServer started supporting HStore and JSON columns for PostGIS data stores. The site says: The PostGIS data store now has simple support for HStore and ...
Diego Victor de Jesus's user avatar
7 votes

GeoJSON java library

Another alternative is GeoGson, which is built on top of Google's Gson: Geometry geometry = new GsonBuilder() .registerTypeAdapterFactory(new GeometryAdapterFactory()) .create() ...
simon04's user avatar
  • 177
7 votes
Accepted

How to create JSON file from GeoJSON

GeoJSON is technically already in JSON format. What do you need to do with the data? You can save GeoJSON data to a file with a .json extension. You can also encode the GeoJSON data to get a string ...
Dylan Hamilton's user avatar
7 votes

How can I convert KMZ file to JSON?

If you include jsZip and toGeoJson in the header of your page and add this to the body <input type="file" id="f"> <textarea id="output" rows="20" cols=&...
Dataform's user avatar
  • 1,356
7 votes
Accepted

Applying JSON style from URL to Vector in OpenLayers

The easiest way to do this is to use the ol-mapbox-style plugin. It has an API that allows you to use Mapbox Style JSONs as style for a specific layer (like in your snippet), but it also allows you to ...
ahocevar's user avatar
  • 3,073
6 votes

Create map using Leaflet and JSON

You have a JSON but Leaflet really likes geoJSONs, so you should convert the JSON to geoJSON first, or directly load a geoJSON. So for your example, if you have: var data =[{ "latitud": 43....
Mfbaer's user avatar
  • 233
6 votes
Accepted

US Cities (from JSON) and USA––Same CRS, Wrong Projection

The problem appears to be here: geometry = [Point(xy) for xy in zip(cities_df['latitude'], cities_df['longitude'])] Latitude is y, longitude is x. Just swap the keys. You can see the transposition ...
Marc Pfister's user avatar
  • 4,097
6 votes
Accepted

How to open REST/JSON service in QGIS?

The JSON returned from that URL does not look like it conforms to any standard format. Any system that could map from that URL would have to know it was an array, with an array of "weatherStations" ...
Spacedman's user avatar
  • 65k
6 votes

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

@toms' answer is perfect -- which I've used for creating my geopackage, btw. Now that I've learned, I want to add to the discussion: GeoDataFrame's to_file method has the following signature: >&...
Brandt's user avatar
  • 245
5 votes
Accepted

Setting names for attributes in properties in json returned by postgresql

I like to use the json_build_object function. SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM ( SELECT 'Feature' As type , ...
caiohamamura's user avatar
  • 1,031
5 votes

Create map using Leaflet and JSON

As an alternative to @Joran's approach, you can skip GeoJSON completely and just iterate through the points, creating instances of L.LatLng and L.Marker as you go, like: var points = [{ "...
IvanSanchez's user avatar
  • 10.3k
5 votes

Converting ArcGIS Server JSON to GeoJSON?

Converting ArcGIS JSON to GeoJSONThere in pure Browser there are 2 ways you can do 1) TERRAFORMER Note: use in node.js and use in browser are different, details see link 2) Esri/arcgis-to-geojson-...
hoogw's user avatar
  • 1,752
5 votes
Accepted

How to download OSM 3D building data?

The .osm.pbf data from Geofabrik conatins ALL OSM data, including the 3D information to render the buildings. You just need the suitable rendering software for it. https://osmbuildings.org/developer/ ...
AndreJ's user avatar
  • 76.7k
5 votes
Accepted

z-index order tile layer and json layer

Read the Leaflet tutorial on map panes. Panes in Leaflet 1.0.x allow exactly what you are asking for: controlling the stacking order of groups of layers. See also https://stackoverflow.com/questions/...
IvanSanchez's user avatar
  • 10.3k
5 votes

GeoJSON not displaying in QGIS

I see the same thing (QGIS 2.18.3) It's all on one line, so I pretty-printed using python 3.5 at the command line... python3.5 -m json.tool ./counties.geojson | less here's what the first few lines ...
Steven Kay's user avatar
  • 20.5k
5 votes
Accepted

Extracting data from ArcGIS REST endpoint

You need to make a request to the ?query endpoint of the layer, and supply a where clause. Specify &f=json to receive the response in JSON. Note that ArcGIS Server by default only returns the ...
Stephen Lead's user avatar
  • 21.2k
5 votes
Accepted

Better performance for geohash aggregation with PostGIS

In PostgreSQL, common table expressions are always materialized. (This will change in version 12.) To allow more optimizations, move bbox into a view, or inline it as a subquery: SELECT COUNT(name), ...
CL.'s user avatar
  • 1,983
5 votes

QGIS not exporting JSON to GeoJSON format

No need for QGIS here. Imagining you have a recent PostgreSQL and PostGIS 3+ (because of function ST_AsGeoJSON), in the command line, you can use the following psql -t test_postgis3 <<EOF > /...
ThomasG77's user avatar
  • 31k
5 votes

Importing JSON data from Internet directly to QGIS

Have a look at https://www.tutorialspoint.com/downloading-files-from-web-using-python and Add layer to map in qgis3 via a python script As the first part of your question was really about Python -it ...
GeorgeC's user avatar
  • 8,238
5 votes
Accepted

GeoJSON will load from variable, but not from file in OpenLayers

When used in a Vector source the GeoJSON parser will attempt to transform coordinates from the default data projection for GeoJSONs (CRS:84) to the view projection. As your coordinates are already in ...
Mike's user avatar
  • 12.6k
5 votes

Loading JSON data into QGIS

For the Capital Regional District (CRD) Basemap you can use: https://mapservices.crd.bc.ca/arcgis/rest/services/ In QGIS you can use the ArcGIS Rest Services Connection.
Mapperz's user avatar
  • 50k

Only top scored, non community-wiki answers of a minimum length are eligible