Hot answers tagged

7

Use ST_GeomFromGeoJSON. SELECT ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[-125045.48351212002,4577567.588141698],[-124816.19981552364,4577552.93014355],[-124765.99472517562,4577419.175847012],[-124842.47121534991,4577392.905406596],[-125045.48351212002,4577567.588141698]]]]}'); Returns: ...


6

Use ST_GeomFromGeoJSON select ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[-125045.48351212002,4577567.588141698],[-124816.19981552364,4577552.93014355],[-124765.99472517562,4577419.175847012],[-124842.47121534991,4577392.905406596],[-125045.48351212002,4577567.588141698]]]]}') Result: ...


5

Your GeoJSON sample lacks information about the coordinate reference system, although you say it is SRID 900913. This is so-called Google Mercator or Web Mercator, which has been superseded by EPSG:3857, which I will use in this example. An important question is whether you really want Well-Known Binary, which does not include an SRID, or Extended Well-Known ...


4

There is a configuration switch for this in GDAL 2.1 onwards: http://www.gdal.org/drv_geojson.html It defaults to 16 decimal places. So upgrading to GDAL 2.1 should solve your issue. If not you can try a higher number of decimal for floating point numbers: -lco SIGNIFICANT_FIGURES=17


4

The L.GeoJson class has a built in filter option that you can use to filter your data. Just pass it a function that will return true for the features you want to show: var picnic_parks = L.geoJson(myJson, {filter: picnicFilter}).addTo(map); function picnicFilter(feature) { if (feature.properties.Picnic === "Yes") return true } Here is a fiddle with a ...


3

Speaking purely from a data storage and analysis perspective, the geography type for PostGIS was designed with the antimeridian in mind (among several design goals). There are several functions specifically designed for the geography type. For instance, consider a LineString across Taveuni, Fiji (mapped with Great Circle Mapper), which straddles the ...


2

This can be done a bit more simply with json_build_object in PostgreSQL 9.4+, which lets you build up a JSON by supplying alternating key/value arguments. For example: SELECT json_build_object( 'type', 'Feature', 'id', gid, 'geometry', ST_AsGeoJSON(geom), 'properties', json_build_object( 'feat_type' : feat_type, ...


2

The invalid GeoJSON object error appears to be a product of your edited code, where the temp variable is actually a string, not a GeoJSON object. From your sample output in the comments, it appears that you are getting an array of GeoJson Polygon objects, which L.geoJson can interpret correctly, so your original code (before the edit) should successfully add ...


2

One option is to use Proj4Leaflet to read the projected GeoJSON. If you have a variable called sampleProjected referencing your GeoJSON (and assuming you are using a projection that is defined in Proj4, as EPSG:3857 is), you could just add it like so: L.Proj.geoJson(sampleProjected).addTo(map); Here is an example comparing your projected data (in blue) ...


2

The shapefile's .prj file does not contain the datum shift parameters from Amersfoort to WGS84, because the ESRI world handles datum shifts differently from the GDAL world. GDAL tries to make a guess about the EPSG code, but sometimes fails. So you have to add explicitely that you have EPSG:28992 data: ogr2ogr -f GeoJSON gem_rd.geojson Gem_2015.shp -t_srs ...


2

Here an example with ST_GeomFromGeoJSON() : select ST_GeomFromGeoJSON ('{"type":"Polygon", "coordinates": [[-74.54635620117188,40.773261878622634], [-74.69741821289062,40.61082491956405], [-74.30740356445312,40.61603737424185], ...


1

Natural Earth has vector data of the Earth in different resolutions. The data comes as shapefiles, but saving to another file format is an easy task for almost all GIS software. Some of them (like QGIS) are free of charge. Note that you can use the data in any scale you want, but low resolution shapes have less vertices. You could try to simplify the ...


1

You do realize that your tutorial for "featureOver" makes you superimpose a new layer / feature above your track. Therefore, the latter can no longer be clicked on. You could either implement your "featureClick" listener on the added layer / feature as well, so that it opens your sidebar. Or you could rather change the display properties of the ...


1

Once you have your geojson back use the ol.format.GeoJSON() to parse the object and create the features. var format = new ol.format.GeoJSON(); var myGeoJsonObj = ....asign the geojson result here var myGeoJsonFeatures = format.readFeatures(myGeoJsonObj ) and then you may place your features in a vector layer using. ...


1

I made a test with OSGeo4W version of GDAL gdalinfo --version GDAL 2.0.2, released 2016/01/26 I created a test point in OpenJUMP JML format with one decimal attribute. <?xml version='1.0' encoding='UTF-8'?> <JCSDataFile xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" > ...


1

To read various file formats for rendering GeoTools uses a DataStoreFinder mechanism that allows you to call it with a Map of keys & parameters and then it searches all the available DataStoreFactories to see which one can process those parameters. For your file based stores all you need to do is: HashMap<String, Object> params = ...


1

Altough I wasn't able to find a bug in the above code... I managed to work it around using another way to load GeoJSON based layers. Another thing, the lat and longs weren't properly ordered in the example given (so that the correspond to positions on Rosario, Argentina)... Below are written correctly. <!DOCTYPE html> <html> <head> ...


1

The geojson layer is in EPSG:4326, not 3857. For the center_coord, you should reproject the degree values to EPSG:900913: new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());


1

You can do that with CartoDB.js. Here you have a working example with a layer selector using buttoms and here another one using a dropdown menu. Applying the first example (where fields is the table, type is the column with two categories -outdoor and indoor-) to your needs. You should first create a div like this: <div id='layer_selector'> ...


1

Municipal ward level maps can be found here: https://github.com/mickeykedia/India-Maps


1

Mapbox's togeojson converter handles this very nicely. It flattens the contents of all layers/folders into sibling features. A bonus: unlike the accepted answer using ogr2ogr to extract each layer/folder, togeojson preserves features in the top-level, and not in any directory. Since it's JavaScript, it can run in your browser at ...



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