Hot answers tagged

5

With the command line, https://gdal.org/programs/gdal_rasterize.html With Python, you can use gdal.RasterizeLayer like in the tests from GDAL e.g https://github.com/OSGeo/gdal/blob/master/autotest/alg/rasterize.py With Java, you can use the same function from Java bindings https://github.com/OSGeo/gdal/blob/master/gdal/swig/java/javadoc.java#L733 (PS: ...


3

When you create marker cluster group from GeoJSON data that contains only points for markers, and you markers will be L.circleMarker markers, you must have the following in mind: You can use L.geoJSON for parsing GeoJSON data, creating desired markers and adding them to cluster, but you don't add GeoJSON layer to the map. Markers of type L.circleMarker are ...


3

You may try the following (tested) ogr2ogr -nln spatial.buildings -dialect SQLite -sql "SELECT geometry AS footprint FROM RhodeIsland" -update -append -gt 65536 -f "PostgreSQL" PG:"<my connection string>" "RhodeIsland.geojson" Using -sql and -dialect SQLite, you are able to remap geometry column correctly You ...


3

Change your query. See https://overpass-turbo.eu/s/17Ng Then, you can export/ download as GEOJSON [out:json][timeout:25]; ( way(167047843); ); out body; >; out skel qt; You can also use this command line utility npm install -g query-overpass and then echo "[out:json][timeout:25]; ( way(167047843); ); out body; >; out skel qt; " | query-...


3

Ogr2ogr is also available as a Python function VectorTranslate. No need to use subprocess. See the API documentation https://gdal.org/python/osgeo.gdal-module.html#VectorTranslate https://gdal.org/python/osgeo.gdal-module.html#VectorTranslateOptions Minimal usage example: from osgeo import gdal srcDS = gdal.OpenEx('test.json') ds = gdal.VectorTranslate('test....


2

Geopandas can accomplish this. Try this: import geopandas as gpd gdf = gpd.read_file('file.geojson') gdf.to_file('file.shp')


2

You need to cast the BOX3D back to a GEOMETRY for ST_AsGeoJSON to make sense of it: SELECT JSONB_BUILD_OBJECT( 'type', 'FeatureCollection', 'features', JSONB_AGG(ST_AsGeoJSON(q.*)::JSONB) ) AS fc FROM ( SELECT 1 AS id, ST_Extent(ST_Expand('POINT(0 0)'::GEOMETRY, 1))::GEOMETRY AS geom ) q ; Note that ST_Extent is ...


2

A working solution using an adapted version of https://github.com/usgs/quakeml-parser-js to deal with the XML (issues with parsing and unwanted "require") I've also use fetch instead of the old xhr/XMLHttpRequest approach (cf https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) <!DOCTYPE HTML> <html lang="en"&...


2

[out:json] produces JSON, not GeoJSON. This is also stated in the documentation Overpass QL, section Output Format. You can convert raw OSM data to GeoJSON by using osmtogeojson. This is also done by Overpass turbo as stated at Overpass_turbo/GeoJSON.


2

Your AJAX success function is creating an array of GeoJSON features. OpenLayers expects OpenLayers features. $.ajax({ url: 'geoJSON-url', dataType: 'json', async: false, success: function(json1) { features = new GeoJSON().readFeatures(json1); } }); It would be simpler to let OpenLayers asychronously load and parse the URL var ...


1

In your loop where you create one GeoJSON layer for each category, just add icon creaton for specific category and then use this icon when creating markers: for (let i = 1; i < 8; i++) { let markerIcon = L.icon({ iconUrl: 'path_to_icon/category' + i + '.png' }); this["category" + i] = L.geoJson(geojsonData, { onEachFeature: ...


1

I still can't understand why the previous code doesn't work but using an alternative approach with pointToLayer and L.Circle seems to achieve the desired effect. var geoJson = new L.geoJSON(geojsonFeature, { pointToLayer: (feature, latlng) => { return new L.Circle([feature.properties.latitude, feature.properties.longitude], feature.properties....


1

it turns out that some data in the coordinate column is null. It causes the error mentioned above.


1

One possibility is to open both GeoJSON in QGIS and familiarize yourself with Processing Toolbox algorithms "Intersection", "Diffference". With both, you will be able to crop at the country frontier and get 3 polygons like below (the selected one in yellow can be removed). You can merge them with "Merge vector layer" algorithm. ...


1

GeoJSON is JSON data, it's easier if you treat it as such. Actually it's probably better to treat it as geospatial data and use a geospatial library, but if you're stuck with the standard library: import json str_data = '''{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"...


1

Your GeoJSON loads just fine for me. Are you making sure to load your script through a server (e.g. using Python http.server)? Could be a CORS issue if you're trying to load the GeoJSON locally.


1

I'm not clear on where you get your key points from but here I'm using the centroids (you can substitute your own points): AffineTransform worldToScreen = mapContent.getViewport().getWorldToScreen(); try (SimpleFeatureIterator it = (SimpleFeatureIterator) features.features()) { while (it.hasNext()) { SimpleFeature feature = it.next(); ...


1

You likely need to adjust the longitude values to -180,180 range from 0-360. See: Clip global data by polygon using rioxarray fails (off by 180 longitude) ds = ds.assign_coords(x=(((ds.x + 180) % 360) - 180)).sortby('x')


1

Geopandas does this without the need to use OGR. import geopandas as gpd gdf = gpd.read_file('file.json') gdf.to_crs('EPSG:3857')


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