Skip to content

Commit bfe1f0e

Browse files
author
farah-alyasari
committed
spatial-io-read-write-spatial-data.md check
1 parent 2fbd787 commit bfe1f0e

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

articles/azure-maps/spatial-io-read-write-spatial-data.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ manager: philmea
1313

1414
# Read and write spatial data
1515

16-
This article outlines all the different tools available in the Spatial IO module for reading and writing spatial data.
17-
18-
The following table is a list of spatial file formats that are supported for reading and writing using the Spatial IO module.
16+
The table below lists the spatial file formats that are supported for reading and writing operations with the Spatial IO module.
1917

2018
| Data Format | Read | Write |
2119
|-------------------|------|-------|
@@ -28,9 +26,11 @@ The following table is a list of spatial file formats that are supported for rea
2826
| Spatial CSV |||
2927
| Well Known Text |||
3028

31-
## Read spatial data
29+
These next sections outline all the different tools for reading and writing spatial data using the Spatial IO module.
30+
31+
## Read spatial data
3232

33-
The `atlas.io.read` function is used to read common spatial data formats such as KML, GPX, GeoRSS, GeoJSON, and CSV files with spatial data. This function can also as read compressed versions of these formats, as a zip file or a KMZ file. The KMZ file format is a compressed version of KML that can also include assets such as images. Alternatively, the read function can take in a URL that points to a file in any of these formats. URLs should be hosted on a CORs enabled endpoint, or a proxy service should be provided in the read options. The read function returns a promise to add the image icons to the map, and processes in asynchronously to minimize impact to the UI thread.
33+
The `atlas.io.read` function is the main function used to read common spatial data formats such as KML, GPX, GeoRSS, GeoJSON, and CSV files with spatial data. This function can also read compressed versions of these formats, as a zip file or a KMZ file. The KMZ file format is a compressed version of KML that can also include assets such as images. Alternatively, the read function can take in a URL that points to a file in any of these formats. URLs should be hosted on a CORs enabled endpoint, or a proxy service should be provided in the read options. The proxy service is used to load resources on domains that aren't CORs enabled. The read function returns a promise to add the image icons to the map, and processes data asynchronously to minimize impact to the UI thread.
3434

3535
When reading a compressed file, either as a zip or a KMZ, it will be unzipped and scanned for the first valid file. For example, doc.kml, or a file with other valid extension, such as: .kml, .xml, geojson, .json, .csv, .tsv, or .txt. Then, images referenced in KML and GeoRSS files are preloaded to ensure they're accessible. Inaccessible image data may load an alternative fallback image or will be removed from the styles. Images extracted from KMZ files will be converted to data URIs.
3636

@@ -48,21 +48,21 @@ The result from the read function is a `SpatialDataSet` object. This object exte
4848

4949
## Examples of reading spatial data
5050

51-
The following code shows how to read a simple spatial data set, and render it on the map using the `SimpleDataLayer` class. The code uses a GPX file pointed it to by a URL.
51+
The following code shows how to read a simple spatial data set, and render it on the map using the `SimpleDataLayer` class. The code uses a GPX file pointed to by a URL.
5252

5353
<br/>
5454

5555
<iframe height='500' scrolling='no' title='Load Spatial Data Simple' src='//codepen.io/azuremaps/embed/yLNXrZx/?height=500&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/azuremaps/pen/yLNXrZx/'>Load Spatial Data Simple</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
5656
</iframe>
5757

58-
The next code demo shows how to read and load KML, or KMZ, to the map. KML can contain ground overlays, which will be in the form of an `ImageLyaer` or `OgcMapLayer`. These overlays must be added on the map separately from the features. Additionally, if the data set has custom icons, those icons need to be loaded in to the maps resources before the features are loaded.
58+
The next code demo shows how to read and load KML, or KMZ, to the map. KML can contain ground overlays, which will be in the form of an `ImageLyaer` or `OgcMapLayer`. These overlays must be added on the map separately from the features. Additionally, if the data set has custom icons, those icons need to be loaded to the maps resources before the features are loaded.
5959

6060
<br/>
6161

6262
<iframe height='500' scrolling='no' title='Load KML Onto Map' src='//codepen.io/azuremaps/embed/XWbgwxX/?height=500&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/azuremaps/pen/XWbgwxX/'>Load KML Onto Map</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
6363
</iframe>
6464

65-
You may optionally provide a proxy service for accessing cross domain assets that may not have CORs enabled. This snippet of code shows you could add the proxy service setting for the above code demo:
65+
You may optionally provide a proxy service for accessing cross domain assets that may not have CORs enabled. This snippet of code shows you could provide a proxy service:
6666

6767
```javascript
6868

@@ -71,7 +71,7 @@ var proxyServiceUrl = window.location.origin + '/CorsEnabledProxyService.ashx?ur
7171

7272
//Read a KML file from a URL or pass in a raw KML string.
7373
atlas.io.read('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1717245/2007SanDiegoCountyFires.kml', {
74-
//Optionally provide a proxy service for accessing cross domain assets that may not have CORs enabled.
74+
//Provide a proxy service
7575
proxyService: proxyServiceUrl
7676
}).then(async r => {
7777
if (r) {
@@ -81,7 +81,7 @@ atlas.io.read('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1717245/2007SanDiego
8181

8282
```
8383

84-
The last code demo in this section shows how to read a delimited file and render it on the map. In this case, the code uses a CSV file that has spatial data columns.
84+
The last demo below shows how to read a delimited file and render it on the map. In this case, the code uses a CSV file that has spatial data columns.
8585

8686
<br/>
8787

@@ -90,9 +90,9 @@ The last code demo in this section shows how to read a delimited file and render
9090

9191
## Write spatial data
9292

93-
There are two main write functions in the spatial IO module. The `atlas.io.write` function generates a string, while the `atlas.io.writeCompressed` function generates a compressed zip file, which contains a text-based file with the spatial data in it. Both of these functions return a promise to add the feature to the file. Also, they both can write any of the following data: `SpatialDataSet`, `DataSource`, `ImageLayer`, `OgcMapLayer`, feature collection, feature, geometry, or an array of any combination of these data types. When writing using either functions, you can specify the desired file format. If the file format isn't specified, then the data will be written as KML.
93+
There are two main write functions in the spatial IO module. The `atlas.io.write` function generates a string, while the `atlas.io.writeCompressed` function generates a compressed zip file. The compressed zip file would contain a text-based file with the spatial data in it. Both of these functions return a promise to add the data to the file. And, they both can write any of the following data: `SpatialDataSet`, `DataSource`, `ImageLayer`, `OgcMapLayer`, feature collection, feature, geometry, or an array of any combination of these data types. When writing using either functions, you can specify the wanted file format. If the file format isn't specified, then the data will be written as KML.
9494

95-
The following tool demonstrates the majority of the write options that can be used with the `atlas.io.write` function.
95+
The tool below demonstrates the majority of the write options that can be used with the `atlas.io.write` function.
9696

9797
<br/>
9898

@@ -101,14 +101,14 @@ The following tool demonstrates the majority of the write options that can be us
101101

102102
## Example of writing spatial data
103103

104-
The following sample allows you to drag and drop and then load spatial files onto the map. You can export GeoJSON data from the map and write it in one of the supported spatial data formats as a string or as a compressed file.
104+
The following sample allows you to drag and drop and then load spatial files on the map. You can export GeoJSON data from the map and write it in one of the supported spatial data formats as a string or as a compressed file.
105105

106106
<br/>
107107

108108
<iframe height='700' scrolling='no' title='Drag and drop spatial files onto map' src='//codepen.io/azuremaps/embed/zYGdGoO/?height=700&theme-id=0&default-tab=result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/azuremaps/pen/zYGdGoO/'>Drag and drop spatial files onto map</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
109109
</iframe>
110110

111-
You may optionally provide a proxy service for accessing cross domain assets that may not have CORs enabled. This snippet of code shows you could incorporate a proxy service for the above code demo:
111+
You may optionally provide a proxy service for accessing cross domain assets that may not have CORs enabled. This snippet of code shows you could incorporate a proxy service:
112112

113113
```javascript
114114

@@ -120,6 +120,7 @@ function readData(data, fileName) {
120120
fileCount++;
121121
//Attempt to parse the file and add the shapes to the map.
122122
atlas.io.read(data, {
123+
//Provide a proxy service
123124
proxyService: proxyServiceUrl
124125
}).then(
125126
//Success
@@ -132,7 +133,7 @@ function readData(data, fileName) {
132133

133134
## Read and write Well Known Text (WKT)
134135

135-
[Well Known Text](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry), often referred to as WKT for short, is an Open Geospatial Consortium (OGC) standard for representing spatial geometries as text. Many geospatial systems support WKT such as Azure SQL and Azure PostgreSQL with the PostGIS plugin. Like most OGC standards, coordinates are formatted as "longitude latitude" to align with the "x y" convention. As an example, a point at longitude -110 and latitude 45 can be written as `POINT(-110 45)` using WKT format. The following table provides details on the geometry types supported for reading and writing WKT.
136+
[Well Known Text](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) (WKT) is an Open Geospatial Consortium (OGC) standard for representing spatial geometries as text. Many geospatial systems support WKT, such as Azure SQL and Azure PostgreSQL using the PostGIS plugin. Like most OGC standards, coordinates are formatted as "longitude latitude" to align with the "x y" convention. As an example, a point at longitude -110 and latitude 45 can be written as `POINT(-110 45)` using the WKT format. The following table provides details on the geometry types supported for reading and writing WKT.
136137

137138
Well-known text can be read using the `atlas.io.ogc.WKT.read` function, and written using the `atlas.io.ogc.WKT.write` function.
138139

@@ -156,10 +157,10 @@ The following code demonstrates reading and writing well-known text back and for
156157

157158
GML is a spatial XML file specification that's often used as an extension to other XML specifications. GeoJSON data can be written as XML with GML tags using the `atlas.io.core.GmlWriter.write` function. The XML that contains GML can be read using the `atlas.io.core.GmlReader.read` function. The read function has two options:
158159

159-
- `isAxisOrderLonLat` - The axis order of coordinates "latitude, longitude" or "longitude, latitude" can vary between data sets and isn't always well defined. By default the GML reader reads the coordinate data as "latitude, longitude", but setting this option to true will read it as "longitude, latitude".
160-
- `propertyTypes` - This option is a key value lookup table where the key is the name of a property in the data set and the value is the object type to cast the value to when parsing. The supported type values are: `string`, `number`, `boolean`, and `date`. If a property isn't in the look up table or the type not defined, it will be parsed as a string.
160+
- The `isAxisOrderLonLat` option - The axis order of coordinates "latitude, longitude" or "longitude, latitude" can vary between data sets, and it isn't always well-defined. By default the GML reader reads the coordinate data as "latitude, longitude", but setting this option to true will read it as "longitude, latitude".
161+
- The `propertyTypes` option - This option is a key value lookup table where the key is the name of a property in the data set. The value is the object type to cast the value to when parsing. The supported type values are: `string`, `number`, `boolean`, and `date`. If a property isn't in the look up table or the type isn't defined, the property will be parsed as a string.
161162

162-
The `atlas.io.read` function will attempt to fallback to the `atlas.io.core.GmlReader.read` function when it detects that the input data is XML, but the data isn't one of the other support spatial XML formats.
163+
The `atlas.io.read` function will default to the `atlas.io.core.GmlReader.read` function when it detects that the input data is XML, but the data isn't one of the other support spatial XML formats.
163164

164165
## Next steps
165166

0 commit comments

Comments
 (0)