|
BLOG
|
Let's say you have a Hosted Feature Layer named worldEQ which contains data on Earthquakes that have occurred throughout the world for the last 50 years: You wish to create a view named worldEQView from this Hosted Feature Layer. To do that, you could use the following snippet: from arcgis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com", "username","password")
# Search for Source Hosted Feature Layer
source_search = gis.content.search("world_earthquakes")[0]
source_flc = FeatureLayerCollection.fromitem(source_search)
# Create View from Source Hosted Feature Layer
new_view = source_flc.manager.create_view(name="worldEQView") This works out great and your view is created: Let's suppose you next want to use the view to show only earthquakes that occurred before the year 1988. Reviewing the Data tab of the view's Item Details, you see that you can filter by a column year_: When you set a View Definition, that definition is defined at the service level. If you quickly set a test definition in the ArcGIS Online/Portal for ArcGIS user interface and take a look at the view service's Service Definition, you'll see the property that needs to be updated is viewDefinitionQuery: Click on 'View' in the View's Item Details page Next, click on the Layer: Click on 'JSON' Scroll all the way to the bottom to see the 'viewDefinitionQuery' property: Note: changing the value of viewDefinitionQuery also updates the related definitionQuery property To update the viewDefinitionQuery property with the ArcGIS API for Python, you do the following: # Search for newly created View
view_search = gis.content.search("worldEQView")[0]
view_flc = FeatureLayerCollection.fromitem(view_search)
# The viewDefinitionQuery property appears under layers
view_layer = view_flc.layers[0]
# Define a SQL query to filter out events past 1988
view_def = {"viewDefinitionQuery" : "year_ < 1988"}
# Update the definition to include the view definition query
view_layer.manager.update_definition(view_def) You should be able to see this update reflected after refreshing the view Item Details page > Visualization Altogether, the script to create a View from the Hosted Feature Layer and then to set a View Definition is: from arcgis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com", "username","password")
# Search for Source Hosted Feature Layer
source_search = gis.content.search("world_earthquakes")[0]
source_flc = FeatureLayerCollection.fromitem(source_search)
# Create View from Source Hosted Feature Layer
new_view = source_flc.manager.create_view(name="worldEQView")
# Search for newly created View
view_search = gis.content.search("worldEQView")[0]
view_flc = FeatureLayerCollection.fromitem(view_search)
# The viewDefinitionQuery property appears under layers
view_layer = view_flc.layers[0]
# Define a SQL query to filter out events past 1988
view_def = {"viewDefinitionQuery" : "year_ < 1988"}
# Update the definition to include the view definition query
view_layer.manager.update_definition(view_def) This can be generalized into a standalone script like this one: import sys
from arcgis import GIS
from arcgis.features import FeatureLayerCollection
def search_layer(conn,layer_name):
search_results = conn.content.search(layer_name, item_type="Feature Layer")
proper_index = [i for i, s in enumerate(search_results)
if '"' + layer_name + '"' in str(s)]
found_item = search_results[proper_index[0]]
flc = FeatureLayerCollection.fromitem(found_item)
return flc
def create_view(conn, source_flc, view_name, layer_index, view_def):
new_view = source_flc.manager.create_view(name=view_name)
# Search for newly created View
view_flc = search_layer(conn, view_name)
# The viewDefinitionQuery property appears under layers
view_layer = view_flc.layers[layer_index]
# Update the definition to include the view definition query
view_layer.manager.update_definition(view_def)
print("View created")
def main():
conn = GIS("https://www.arcgis.com",
"username", "password")
# Index of the Layer to be filtered
layer_index = 0
# Define a SQL query to filter out events past 1988
view_def = {"viewDefinitionQuery" : "year_ < 1988"}
# Search for target Hosted Feature Layer
source_flc = search_layer(conn, "world_earthquakes")
# Create View from Hosted Feature Layer
create_view(conn, source_flc, "worldEQView", layer_index, view_def)
if __name__ == '__main__':
sys.exit(main()) If you need to define an area of interest, this would be approached like so: view_def = {"viewLayerDefinition":{"filter":
{"operator":"esriSpatialRelIntersects","value":
{"geometryType":"esriGeometryEnvelope","geometry":
{"xmin":4485937.7074932605,"ymin":1543545.165101517,
"xmax":9417043.276225261,"ymax":6239836.182941515,
"spatialReference":{"wkid":102100,"latestWkid":3857}}}}}}
view_layer.manager.update_definition(update_dict)
For further information on how to define an area of interest, please see this post by Egge-Jan Pollé : https://community.esri.com/people/EPolle_TensingInternational/blog/2019/03/27/create-view-from-hosted-feature-layer-and-define-area-of-interest
... View more
02-11-2019
03:23 PM
|
13
|
20
|
14217
|
|
POST
|
Jared, this one has tripped me up in the past as well! You'd certainly think the result would open automatically but that is not the case. Instead, you'll go to Catalog > Project > Maps to locate the imported .aprx.
... View more
02-11-2019
08:31 AM
|
2
|
0
|
3394
|
|
POST
|
I think you should be able to achieve the desired result using only wget: wget "https://gis.trimbul.com/arcgis/rest/services/trees/zashtiteniteritorii/MapServer/0/query?where=Type_Name_+LIKE+'%резерват%'&f=kmz" -O test.kmz
... View more
02-10-2019
08:38 PM
|
2
|
0
|
6449
|
|
POST
|
I think this would be determined by your current cleanup schedule settings: About server directories—ArcGIS Server Administration (Linux) | ArcGIS Enterprise If I understand your problem correctly, you may want to take a look at your uploads folder to see what's in there after running your tests. I've had similar issues when testing upload of large raster datasets to an Image Service.
... View more
02-10-2019
05:56 PM
|
0
|
0
|
1255
|
|
POST
|
Sorry, can you answer the other questions as well? What are the specs of the machine? Is it just PostgreSQL installed on the machine? What is the Geodatabase version? Also, what is the version of the client you are editing with?
... View more
01-24-2019
12:21 PM
|
0
|
1
|
2713
|
|
POST
|
I think a bit more information might help - which version of PostgreSQL is this (i.e., what is the result of select version();)? What are the specs of the machine? Is it just PostgreSQL installed on the machine? What is the Geodatabase version?
... View more
01-24-2019
07:46 AM
|
0
|
3
|
2713
|
|
POST
|
Hi Robert, Out of curiosity, what happens when you try to access an ArcGIS Server resource (let's say the Admin page) on the server machine itself? Does curl http:localhost:6080/arcgis/admin/login return anything?
... View more
01-07-2019
04:16 PM
|
0
|
0
|
794
|
|
POST
|
No problem. If anyone out there is interested, you can greatly simplify your work by creating a Web Map with some sample data and adding whatever styles, labels, options, etc. From there, you can go to (where itemID is the item id of the Web Map): https://machine.domain.com/portal/sharing/rest/content/items/<itemID>/data or https://www.arcgis.com/sharing/content/items/<itemID>/data to get the dictionary used in: data = {"operationalLayers": [],"baseMap": {"baseMapLayers"........ This is probably the easiest way to figure out how to structure the JSON to create a Web Map. Note that if the Web Map is secured you'll need to append a token to the URL. Also, remember that if you're not reading the JSON from a file true will need to be changed to True.
... View more
12-12-2018
11:52 AM
|
0
|
0
|
1616
|
|
POST
|
Hi Jonathan, I believe I am indirectly assisting you with this issue but for the benefit of others this is how you would accomplish the result. You can do this two ways: Using only the ArcGIS API for Python: It is recommended to use an in-memory python dictionary object. Since we're dealing with a Web Map you don't want to use data=jsonfile.json. Rather, you want to set the aforementioned in-memory dictionary as the value of the ‘text’ attribute in the 'item_properties' argument. This is explained here: arcgis.gis module — arcgis 1.5.1 documentation text Optional string. For text based items such as Feature Collections & WebMaps I used a simplified version of your original JSON so you'll just need to add/update the parts you need... # Import modules
from arcgis.gis import GIS
from arcgis.mapping import WebMap
# Login into portal
gis = GIS("PORTALURL","LOGIN","PASSWORD")
# This is the JSON used to create the Web Map, using your two layers as a basemap
data = {"operationalLayers": [],"baseMap": {"baseMapLayers": [{"id": "labels","opacity": 1,"visibility": True,"url": "https://geoappext.nrcan.gc.ca/arcgis/rest/services/BaseMaps/CBMT_CBCT_GEOM_3857/MapServer"},{"id": "base","opacity": 1,"visibility": True,"url": "https://geoappext.nrcan.gc.ca/arcgis/rest/services/BaseMaps/CBMT_TXT_3857/MapServer"}],"title": "Text"}}
# Fill this out as you see fit, the key part is the "text" attribute
item_properties_dict = {"type": "Web Map","title": "Test Map","tags": ["test","basemap","pythonapi"],"snippet":"This is a snippet", "text":data}
newmap = gis.content.add(item_properties = item_properties_dict)
newmap # Optionally, to display the result in Jupyter Notebook Reading from a JSON File: If you prefer to read from a file, then you will need to incorporate the JSON module: # Import modules
from arcgis.gis import GIS
from arcgis.mapping import WebMap
import json
# Login into portal
gis = GIS("PORTALURL","LOGIN","PASSWORD")
# Read the json file (here named test2.json
with open('/path/to/file/test2.json') as json_data:
data = json.load(json_data)
# Again, fill this out as you see fit with the key part being the "text" attribute
item_properties_dict = {"type": "Web Map","title": "Test Map","tags": ["test","basemap","pythonapi"],"snippet":"This is a snippet", "text":data}
newmap = gis.content.add(item_properties = item_properties_dict)
newmap # Optionally, to display the result in Jupyter Notebook Where test2.json is a file with the below contents: {
"operationalLayers": [],
"baseMap": {
"baseMapLayers": [{
"id": "labels",
"opacity": 1,
"visibility": true,
"url": "https://geoappext.nrcan.gc.ca/arcgis/rest/services/BaseMaps/CBMT_CBCT_GEOM_3857/MapServer"
}, {
"id": "base",
"opacity": 1,
"visibility": true,
"url": "https://geoappext.nrcan.gc.ca/arcgis/rest/services/BaseMaps/CBMT_TXT_3857/MapServer"
}
],
"title": "Text"
}
} Here note that true is lowercase - in this case, you need to make this lowercase or else the json will fail to load. It needs to be capitalized, on the other hand, if you just use the API.
... View more
11-28-2018
02:46 PM
|
2
|
2
|
1616
|
|
POST
|
Hi Aaron, You asked this question some time ago but which settings did you choose for Quality and DPI when exporting? You can also try exporting to tiff and converting to PDF from there.
... View more
11-19-2018
05:02 PM
|
0
|
0
|
599
|
|
POST
|
Hi Dan, From what you describe it sounds like there may be a few ways to approach this - in any case, they all involve trust. At first glance, it appears you're establishing a connection to your server via port 6080: "arcgis on mobjack.vims.edu_6080 (publisher)" - what happens when you try the secured port 6443? Is the internal ArcGIS Server Web Server still using the out-of-the-box self-signed certificate or the certificate is issued to *.vims.edu? Alternately, you can establish a connection via the Web Adaptor (assuming you have one set up). I presume that the Web Server where the Web Adaptor is deployed would be using the certificate is issued to *.vims.edu. You'll want to make sure that certificate is installed and trusted on the machine used to run the script. Hope this helps!
... View more
07-24-2018
02:29 PM
|
1
|
1
|
974
|
|
POST
|
Janie, as Randall stated above we officially support "JBoss Enterprise Application Platform 7": ArcGIS Web Adaptor 10.5.x system requirements—ArcGIS Enterprise system requirements | ArcGIS Enterprise While the innards of WildFly should more or less be the same as JBoss it's important to state that only JBoss is supported by name and so there may exist certain limitations on Technical Support should you run into issues. That being said, it is technically possible to do so and I have deployed on Wildfly 11 on numerous occasions for setup of test environments. There are some quirks (for example, certain pages in Server Manager not appearing correctly) but these are usually browser-specific. I have to agree with Randall that the performance boost is probably negligible in this case as you should also consider the hit you'll take if you're running the full-blown JEE stack version. I'm not sure about your needs but if you're set on not using Apache Tomcat, I would recommend: Reaching out to Esri Support Services to clarify the scope of support for WildFly - there's no point in spending the time to set up the environment if you can't get support for it. Since from our documentation JBoss EAP 7 is listed as supported and it is also stated that "Future updates on these application/web servers are supported unless otherwise stated," I can see WildFly 10/11 lying in the grey area as these should roughly equate to JBoss EAP 7/7.1. WildFly 13 might be pushing it as this one I think marks the development of EAP 8 (although it runs on 7 by default). If you find that it is acceptable to run a WildFly configuration, I'd suggest using the servlet-only distribution if you'd don't need all the extra functionality - this will cut back on both file size and CPU usage. Considering another Java EE Application Server which is supported by name. I have deployed on GlassFish 4.1.1 and the setup and configuration for that was quite simple.
... View more
07-02-2018
03:19 PM
|
0
|
0
|
982
|
|
POST
|
Hi Jay - forget about the ArcGIS Monitor branding on the page for a moment. System Log Parser was (and still is) a standalone executable. For a better description of what the tool does see this page: https://www.arcgis.com/home/item.html?id=90134fb0f1c148a48c65319287dde2f7 - really all that's happened here is that the download page has changed. No MongoDB required.
... View more
07-02-2018
08:13 AM
|
0
|
0
|
1146
|
|
POST
|
Jay, I believe System Log Parser could be useful to you: https://arcgismonitor.maps.arcgis.com/home/item.html?id=dacebd64a0a04c87b1c48905e2cfc70d This is basically a handy tool which generates an excel spreadsheet report of all of your ArcGIS Server Services (names, min/max instances, etc.). Alternately, you could use a python script for the purpose just as this one: Example: Write properties of all services to a CSV file—ArcGIS Server Administration (Windows) | ArcGIS Enterprise
... View more
06-29-2018
01:45 PM
|
0
|
1
|
1146
|
|
POST
|
David, please see my response on this related thread: Adding feature class and applying symbology in ArcGIS Pro using arcpy It seems you are running into BUG-000108497: Running Apply Layer Symbology as a script in the Python window does not update the symbology in the map.
... View more
06-29-2018
11:05 AM
|
2
|
1
|
6614
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 01-18-2024 01:34 PM | |
| 1 | 09-13-2023 06:48 AM | |
| 1 | 09-23-2022 09:04 AM | |
| 1 | 06-14-2024 01:14 PM | |
| 2 | 09-24-2019 08:22 AM |