Hi David, Just to add to what Adam said: the JSON that Adam sent in his previous message is an example of how you might use Arches’s built-in tileserver to create a vector tile service using a table in PostgreSQL and add that service as an overlay to Arches.
I see in your original message that you had some GeoJSON embedded in your tileserver layer JSON. If you just want to add a static GeoJSON layer (for example, one like this: http://bl.ocks.org/d/ef52412364feacb59192efe73045068d <http://bl.ocks.org/d/ef52412364feacb59192efe73045068d>) then you can create a GeoJSON source and bypass the tileserver entirely. To do this, you will instead be using the “add_mapbox_layer“ command.This is especially useful if you have a small dataset (like the one that your provided) and don’t need any of PostGIS’s spatial processing capabilities (such as the clustering functions we use for resource layers by default). Here is a link to an example of how you might add such a static GeoJSON layer: https://gist.github.com/robgaston/d0e3db6b966837be65031d2300a0801d <https://gist.github.com/robgaston/d0e3db6b966837be65031d2300a0801d> You’re probably best off just: 1) downloading the JSON file in the gist, 2) putting that file in the same folder as your project’s manage.py file 3) scraping the content of add-example-points-layer.sh and running that manually at a command line from your project’s folder. I hope that helps! - Rob > On Jan 29, 2018, at 9:22 AM, Adam Cox <[email protected]> wrote: > > Hi David, you're correct that this is a JSON syntax error. I used this handy > tool https://jsonlint.com/ <https://jsonlint.com/> to test it. It also > formats the code in a way that makes it easier to visualize JSON syntax. > > Ultimately, the change that needs to happen is moving the ] that is near the > very end to a position right before the "config" section and adding a , after > it. So the following is valid JSON: > > { > "type": "FeatureCollection", > "features": [{ > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I3", > "KML_FOLDER": "Arcos de Valdevez" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.450217, 41.938804] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M", > "KML_FOLDER": "Arcos de Valdevez" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.343963, 41.870299] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M", > "KML_FOLDER": "Arcos de Valdevez" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.389271, 41.868684] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I1", > "KML_FOLDER": "Caminha" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.832159, 41.873065] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M0", > "KML_FOLDER": "Caminha" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.838441, 41.801253] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M0", > "KML_FOLDER": "Caminha" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.841388, 41.809651] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M0", > "KML_FOLDER": "Caminha" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.787310, 41.906306] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M0", > "KML_FOLDER": "Caminha" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.850757, 41.809936] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_V1", > "KML_FOLDER": "Melgaço" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.098310, 42.070975] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M1", > "KML_FOLDER": "Melgaço" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.279876, 42.092524] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_M1", > "KML_FOLDER": "Monção" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.452002, 42.027202] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_V0", > "KML_FOLDER": "Ponte da Barca" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.251466, 41.840543] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I2", > "KML_FOLDER": "Paredes de Coura" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.627916, 41.873977] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_C", > "KML_FOLDER": "Ponte de Lima" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.560746, 41.795792] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I", > "KML_FOLDER": "Ponte de Lima" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.605898, 41.780252] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I", > "KML_FOLDER": "Ponte de Lima" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.611713, 41.715959] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I", > "KML_FOLDER": "Ponte de Lima" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.612457, 41.694275] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I", > "KML_FOLDER": "Ponte de Lima" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.607588, 41.694813] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I", > "KML_FOLDER": "Ponte de Lima" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.643646, 41.792144] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_V", > "KML_FOLDER": "Valença" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.639526, 42.002488] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I0", > "KML_FOLDER": "Valença" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.588610, 41.997460] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_E", > "KML_FOLDER": "Vila Nova de Cerveira" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.739175, 41.952262] > } > }, > { > "type": "Feature", > "properties": { > "KML_STYLE": "msn_I2", > "KML_FOLDER": "Vila Nova de Cerveira" > }, > "geometry": { > "type": "Point", > "coordinates": [-8.697189, 41.888439] > } > } > ], > "config": { > "provider": { > "class": "TileStache.Goodies.VecTiles:Provider", > "kwargs": { > "dbinfo": { > "host": "localhost", > "user": "postgres", > "password": "XXXXXXX", > "database": "arches", > "port": "5432" > }, > "simplify": 0.5, > "queries": [ > "select gid as __id__, name, > st_asgeojson(geom) as geojson, st_transform(geom, 900913) as __geometry__ > from arqueologia" > ] > } > }, > "allowed origin": "*", > "compress": true, > "write cache": false > } > } > > However, I'm unsure what the purpose of the "features" section... Are those > additional points that you would like to show in addition to the contents of > arqueologia? If so, I think you'll need to accomplish that in a different > way. As described in the docs (which, apologies, but that section has move > here: http://arches4.readthedocs.io/en/stable/creating-new-map-layers/ > <http://arches4.readthedocs.io/en/stable/creating-new-map-layers/> with the > recent 4.1 release) there should only be three main sections of of the JSON > contents: > > { > "type" : ## This value should be "raster" or "vector". > "layers" : ## This is a mapbox.js layer definition which defines the style > ## of the layer and links the source name with the layer name. > "config" : ## This is the tileserver configuration that will be used by > ## TileStache. Refer to TileStache docs and place the entire > ## "provider" section into this "config" section. > } > In your case, I believe it would look like this: > > { > "type": "vector", > "layers": [{ > "id": "arqueologia", > "type": "line", > "source": "arqueologia", > "source-layer": "arqueologia", > "layout": { > "visibility": "visible" > }, > "paint": { > "line-width": 2, > "line-color": "rgb(37, 58, 241)" > } > }], > "config": { > "provider": { > "class": "TileStache.Goodies.VecTiles:Provider", > "kwargs": { > "dbinfo": { > "host": "localhost", > "user": "postgres", > "password": "XXXXXX", > "database": "arches", > "port": "5432" > }, > "simplify": 0.5, > "queries": [ > "select gid as __id__, name, st_asgeojson(geom) as > geojson, st_transform(geom, 900913) as __geometry__ from arqueologia" > ] > } > }, > "allowed origin": "*", > "compress": true, > "write cache": false > } > } > I've been trying this out with a local postgis table of my own (not rivers) > and have some more notes from the experience: > To be on the safe side, I put the name of my postgis table in the id, source, > and source-layer properties of the first entry of the layers section. I think > a couple of these properties get overwritten on load and therefore are not > necessary, but I just wanted to follow the rivers example. > Inside the layer definition, type and paint must be coordinated well. For > type, the options are fill, line, symbol, circle, fill-extrusion, raster, or > background. In my case, I was trying out a polygon layer, so I needed fill. > For points, I'm assuming symbol or circle would work.. > Once the layer type is set, then you have to use to correct paint properties > to fit that type. This is where the Mapbox GL JS style spec is necessary, > https://www.mapbox.com/mapbox-gl-js/style-spec/ > <https://www.mapbox.com/mapbox-gl-js/style-spec/>. If you are styling a > symbol layer, then you are only able to use the paint properties listed here > https://www.mapbox.com/mapbox-gl-js/style-spec/#layers-symbol > <https://www.mapbox.com/mapbox-gl-js/style-spec/#layers-symbol>. Once the > layer is loaded however, you can further edit its style in the Layer Manager > (use the Service Styling tab). > In the queries section, note that there a 3 different column names in the > example, and the column names in your own table may be different. In my case > geom and name did indeed exist, however I needed to change gid to id. > Hope that helps you out a bit! > > Adam > > > > On Mon, Jan 29, 2018 at 8:04 AM, David Lopes <[email protected] > <mailto:[email protected]>> wrote: > Hi Adam, > > It's me again regarding the same subject. > > I've already successfully loaded the sql files to the database (arches) and > executed the python commad for the json files but I get the following error > message: > > > operation: add_tileserver_layer > package: arches > Traceback (most recent call last): > File "manage.py", line 27, in <module> > execute_from_command_line(sys.argv) > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/ > management/__init__.py", line 364, in execute_from_command_line > utility.execute() > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/ > management/__init__.py", line 356, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/ > management/base.py", line 283, in run_from_argv > self.execute(*args, **cmd_options) > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/ > management/base.py", line 330, in execute > output = self.handle(*args, **options) > File "/home/ubuntu/Projects/arches/arches/management/commands/packages.py", > li ne 188, in handle > self.add_tileserver_layer(options['layer_name'], > options['mapnik_xml_path'], options['layer_icon'], > options['is_basemap'], options['tile_config_path']) > File "/home/ubuntu/Projects/arches/arches/management/commands/packages.py", > li ne 907, in add_tileserver_layer > config_data = json.load(content) > File "/usr/lib/python2.7/json/__init__.py", line 291, in load > **kw) > File "/usr/lib/python2.7/json/__init__.py", line 339, in loads > return _default_decoder.decode(s) > File "/usr/lib/python2.7/json/decoder.py", line 364, in decode > obj, end = self.raw_decode(s, idx=_w(s, 0).end()) > File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode > obj, end = self.scan_once(s, idx) > ValueError: Expecting , delimiter: line 51 column 2 (char 3923) > > Since I am almost sure it has something to do with the sintax of the json > file (I am not a programmer), I join the file (with no password) in the hope > that you can help me: > > { > "type": "FeatureCollection", > "features": [ > { "type": "Feature", "properties": { "KML_STYLE": "msn_I3", "KML_FOLDER": > "Arcos de Valdevez" }, "geometry": { "type": "Point", "coordinates": [ > -8.450217, 41.938804 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M", "KML_FOLDER": > "Arcos de Valdevez" }, "geometry": { "type": "Point", "coordinates": [ > -8.343963, 41.870299 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M", "KML_FOLDER": > "Arcos de Valdevez" }, "geometry": { "type": "Point", "coordinates": [ > -8.389271, 41.868684 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I1", "KML_FOLDER": > "Caminha" }, "geometry": { "type": "Point", "coordinates": [ -8.832159, > 41.873065 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M0", "KML_FOLDER": > "Caminha" }, "geometry": { "type": "Point", "coordinates": [ -8.838441, > 41.801253 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M0", "KML_FOLDER": > "Caminha" }, "geometry": { "type": "Point", "coordinates": [ -8.841388, > 41.809651 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M0", "KML_FOLDER": > "Caminha" }, "geometry": { "type": "Point", "coordinates": [ -8.787310, > 41.906306 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M0", "KML_FOLDER": > "Caminha" }, "geometry": { "type": "Point", "coordinates": [ -8.850757, > 41.809936 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_V1", "KML_FOLDER": > "Melgaço" }, "geometry": { "type": "Point", "coordinates": [ -8.098310, > 42.070975 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M1", "KML_FOLDER": > "Melgaço" }, "geometry": { "type": "Point", "coordinates": [ -8.279876, > 42.092524 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_M1", "KML_FOLDER": > "Monção" }, "geometry": { "type": "Point", "coordinates": [ -8.452002, > 42.027202 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_V0", "KML_FOLDER": > "Ponte da Barca" }, "geometry": { "type": "Point", "coordinates": [ > -8.251466, 41.840543 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I2", "KML_FOLDER": > "Paredes de Coura" }, "geometry": { "type": "Point", "coordinates": [ > -8.627916, 41.873977 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_C", "KML_FOLDER": > "Ponte de Lima" }, "geometry": { "type": "Point", "coordinates": [ -8.560746, > 41.795792 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I", "KML_FOLDER": > "Ponte de Lima" }, "geometry": { "type": "Point", "coordinates": [ -8.605898, > 41.780252 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I", "KML_FOLDER": > "Ponte de Lima" }, "geometry": { "type": "Point", "coordinates": [ -8.611713, > 41.715959 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I", "KML_FOLDER": > "Ponte de Lima" }, "geometry": { "type": "Point", "coordinates": [ -8.612457, > 41.694275 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I", "KML_FOLDER": > "Ponte de Lima" }, "geometry": { "type": "Point", "coordinates": [ -8.607588, > 41.694813 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I", "KML_FOLDER": > "Ponte de Lima" }, "geometry": { "type": "Point", "coordinates": [ -8.643646, > 41.792144 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_V", "KML_FOLDER": > "Valença" }, "geometry": { "type": "Point", "coordinates": [ -8.639526, > 42.002488 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I0", "KML_FOLDER": > "Valença" }, "geometry": { "type": "Point", "coordinates": [ -8.588610, > 41.997460 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_E", "KML_FOLDER": > "Vila Nova de Cerveira" }, "geometry": { "type": "Point", "coordinates": [ > -8.739175, 41.952262 ] } } > , > { "type": "Feature", "properties": { "KML_STYLE": "msn_I2", "KML_FOLDER": > "Vila Nova de Cerveira" }, "geometry": { "type": "Point", "coordinates": [ > -8.697189, 41.888439 ] } } > > > "config": { > "provider": { > "class": "TileStache.Goodies.VecTiles:Provider", > "kwargs": { > "dbinfo": { > "host": "localhost", > "user": "postgres", > "password": "XXXXXXX", > "database": "arches", > "port": "5432" > }, > "simplify": 0.5, > "queries": [ > "select gid as __id__, name, > st_asgeojson(geom) as geojson, st_transform(geom, 900913) as __geometry__ > from arqueologia" > ] > } > }, > "allowed origin": "*", > "compress": true, > "write cache": false > } > > > > ] > } > > > Once again thanks, > > > > > > sexta-feira, 19 de Janeiro de 2018 às 15:18:47 UTC, Adam Cox escreveu: > Based on the example here > http://arches4.readthedocs.io/en/stable/managing-map-layers/#tileserver-layers > > <http://arches4.readthedocs.io/en/stable/managing-map-layers/#tileserver-layers>, > you can see that the db info is in the "config" section of the .json file > (if you are making a layer based on a postgis table). It occurs to me now > that you should be wary of sharing config files such as this, as they would > likely contain the credentials to your Arches pg database (unless you are > pulling from another database... either way, you shouldn't share those > credentials...). > > Adam > > On Fri, Jan 19, 2018 at 9:13 AM, David Lopes <[email protected] <>> wrote: > Adam, > > One more question: the .json file requires a few lines connecting with the > database, right? > > Best regards. > > > > quinta-feira, 18 de Janeiro de 2018 às 18:04:17 UTC, Adam Cox escreveu: > FYI I just tested loading the sql from that repo example and then loading the > tile layer with the config file that's in there, and the layer loaded > correctly. > > On Thu, Jan 18, 2018 at 9:59 AM, Adam Cox <[email protected] <>> wrote: > Hi David, are you using a config file from the repo, or have you made a new > one? From looking at the error, it seems like the config file you are using > may have [ ] in the outermost position instead of { }, but the config files > in that repo do look fine to me. > > Adam > > On Thu, Jan 18, 2018 at 9:13 AM, David Lopes <[email protected] <>> wrote: > Hi, > > I've been trying to add .sql and .json files to the data base without success > (https://github.com/legiongis/arches4-geo-examples > <https://github.com/legiongis/arches4-geo-examples>) > > I get the following message: > > operation: add_tileserver_layer > package: arches > Traceback (most recent call last): > File "manage.py", line 27, in <module> > execute_from_command_line(sys.argv) > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/management/__init__.py", > line 364, in execute_from_command_line > utility.execute() > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/management/__init__.py", > line 356, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/management/base.py", > line 283, in run_from_argv > self.execute(*args, **cmd_options) > File > "/home/ubuntu/Projects/ENV/local/lib/python2.7/site-packages/django/core/management/base.py", > line 330, in execute > output = self.handle(*args, **options) > File "/home/ubuntu/Projects/arches/arches/management/commands/packages.py", > line 188, in handle > self.add_tileserver_layer(options['layer_name'], > options['mapnik_xml_path'], options['layer_icon'], options['is_basemap'], > options['tile_config_path']) > File "/home/ubuntu/Projects/arches/arches/management/commands/packages.py", > line 908, in add_tileserver_layer > config = config_data["config"] > TypeError: list indices must be integers, not str > > Can you tell what's wrong? > > Thanks > > -- > -- To post, send email to [email protected] <>. To unsubscribe, send > email to [email protected] <>. For more information, visit > https://groups.google.com/d/forum/archesproject?hl=en > <https://groups.google.com/d/forum/archesproject?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "Arches Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > > -- > -- To post, send email to [email protected] <>. To unsubscribe, send > email to [email protected] <>. For more information, visit > https://groups.google.com/d/forum/archesproject?hl=en > <https://groups.google.com/d/forum/archesproject?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "Arches Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > -- To post, send email to [email protected] > <mailto:[email protected]>. To unsubscribe, send email to > [email protected] > <mailto:archesproject%[email protected]>. For more information, > visit https://groups.google.com/d/forum/archesproject?hl=en > <https://groups.google.com/d/forum/archesproject?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "Arches Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > -- To post, send email to [email protected]. To unsubscribe, > send email to [email protected]. For more > information, visit https://groups.google.com/d/forum/archesproject?hl=en > <https://groups.google.com/d/forum/archesproject?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "Arches Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- -- To post, send email to [email protected]. To unsubscribe, send email to [email protected]. For more information, visit https://groups.google.com/d/forum/archesproject?hl=en --- You received this message because you are subscribed to the Google Groups "Arches Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
