D 2019-12-26T15:52:39.912 L Supporting\sGeoJSON P 56fbb6b4917c1100c41821e35ebbca0c76b0aeb2 U sandro W 23226 Back to 5.0.0-doc main page
Topic | Shapefile | GML | GeoJSON | Remarks | |
---|---|---|---|---|---|
File organization | At least three independent files sharing the same name and respectively identified by suffixes .shp, .shx and .dbf
|
GML is based on XML, and is just a single, monolithic text file. As any other XML file, GML too can be strongly constrained to conform to a formally defined XML Schema |
Single monolithic text file. Similar to XML, but intended to be far simpler and less verbose. |
The three-files layout of Shapefile is clearly obsolete, and it frequently poses many headaches causing unexpected troubles. The single-file layout adopted by both GML and GeoJSON is clearly better and safer, and being text files they can be easily inspected and eventually debugged just using any generic text editor without requiring any specific tool. |
|
Geometry classes |
Notes:
|
GML allows many different ways to define the same type of Geometry, and the specifications have radically changed from version to version. GML has a really impressive flexibility (e.g. each single Geometry can freely declare its own SRID), but at the cost of imposing an overwhelming complexity. |
Notes:
|
|
|
Dimensions |
|
|
Note: RFC 7946 just supports 2 or 3 coordinates, and the third value (when declared) is always expected to correspond to an Elevation (Z axis). Supporting XYM or XYZM is not technically unfeasible. Both writers and readers could support such options, but all this is surely outside the standard and will surely impair the universal portability of any non canonical file. |
GeoJSON lacks the capability to support XYM and XYZM, other than by adopting (and to others unknown) vicious tricks. May well be it's not a forbidding limitation in many common cases, but it's indisputably a limitation. |
|
SRID |
Not internally declared by the Shapefile itself. Deploying a further .prj file describing the intended SRID is the usual solution adopted by ESRI itself, but correctly parsing these extra files is an usually flimsy process falling outside real capabilities of many third party readers. |
Each single Geometry is allowed to freely define its own SRID, as well as defining the SRID for the whole layer. |
Accordingly to RFC 7946 all coordinates are always expected to be expressed as longitudes and latitudes ((i.e: x-position and y-position). So any canonical GeoJSON file is always expected to reference SRID=4326 WGS 84 (i.e. the SRID is not stored within the GeoJSON file). Using any other SRID is technically possible, but requires a conventional agreement between writers and readers, but all this is surely outside the standard and will surely impair the universal portability of any non canonical file. |
The unique effective solution is the one adopted by GML. Both Shapefile and GeoJSON are clearly inferior under this peculiar aspect. |
|
Non-spatial attributes |
Note: all attribute names are limited to a length of max. 10 bytes. There is no safe way for declaring NULL values. |
Any possible datatype you can imagine. And defining further derived datatypes is an option supported by the XML Schema. Note: attribute names and text values can have any arbitrary length. |
Note: attribute names can have any arbitrary length. |
|
|
Charset encoding
|
Not internally defined by the Shapefile itself. Attempting to guess the appropriate charset encoding required by some Shapefile is more a magic art than rational science. |
Always internally defined by the GML/XML file itself. |
RFC 7946 strictly requires that all GeoJSON files must be encoded as UTF-8 In pure theory both UTF-16 and UTF-32 could be used for encoding a legitimate GeoJSON file, but such options seems to be very rarely (if ever) adopted in real world. |
|
CaveatA similar function named ExportGeoJSON() was already supported by previous versions of SpatiaLite, but it was modelled against the old (pre-RFC) GeoJSON specification.ExportGeoJSON() is now DEPRECATED, and will remain to avoid breaking existing applications and scripts. It is strongly recommended to use ExportGeoJSON2() for any new development as full replacement conformant to RFC 7946. |
WarningThis SQL function open the door to many potential security issues, and thus is always disabled by default.Explicitly setting the external variable SPATIALITE_SECURITY=relaxed is absolutely required in order to enable this function. |
WarningThis SQL function open the door to many potential security issues, and thus is always disabled by default.Explicitly setting the external variable SPATIALITE_SECURITY=relaxed is absolutely required in order to enable this function. |
Two new buttons have been added to the toolbar:
|
![]() |
The side figure is an example of the dialog box that's used for setting options when creating a new Spatial Table by importing data from an external GeoJSON file. |
![]() |
The side figure is an example of the dialog box that's used for setting options when creating a VirtualGeoJSON Table. |
![]() |
For exporting a whole Spatial Table into an external GeoJSON file:
|
![]() |