|
POST
|
Hi Herman Groeneveld, Yeah, you cannot query a WFS service when you use the GetCapabilities request. By default all features from the WFS source are added to the feature class. It is cool that you can use the extent environment setting to set a bounding box. I didn't know that.... But no, I do not get it running either. I tried to set the Extent (Environment setting) in both RD_New and WGS84, but in both cases I run into the same ERROR 999999 like you... Below you will find the code I used to test this. Tip: maybe you should ask this in a new question on GeoNet, to see whether someone from the wider community can help. BR, Egge-Jan # Name: WFSToFeatureClass_example1.py
# Description: Create a feature class from a WFS service
# Import arcpy module
import arcpy
# Set the extent environment using the Extent class.
# arcpy.env.extent = arcpy.Extent(140000, 448000, 170000, 478000) # Coordinates in RD_New (28992)
arcpy.env.extent = arcpy.Extent(5.1686749, 52.0201494, 5.6070564, 52.2897848) # Coordinates in WGS84 (4326)
# Set local variables
WFS_Service = "https://geodata.nationaalgeoregister.nl/cbspostcode4/wfs?&request=GetCapabilities&service=wfs"
WFS_FeatureType = "postcode42017"
Out_Location = "C:/Data/output.gdb"
Out_Name = "postcode42017_new"
# Execute the WFSToFeatureClass tool
arcpy.WFSToFeatureClass_conversion(WFS_Service, WFS_FeatureType, Out_Location, Out_Name) .
... View more
06-19-2019
07:23 AM
|
2
|
1
|
4376
|
|
BLOG
|
https://community.esri.com/people/EPolle_TensingInternational/blog/2019/06/02/aan-de-slag-met-arcgis-javascript-inleiding FeatureLayer Esri Nederland heeft een Feature Layer met Nederlandse gemeenten (voor het jaar 2019) gepubliceerd via ArcGIS Online. Deze laag gaan we als FeatureLayer toevoegen aan onze webapplicatie. Vervolgens passen we de stijl van de laag aan door het toepassen van een renderer. En we definiëren een popupTemplate om gegevens over de gemeente in een popup te kunnen tonen. Ten slotte voegen we een LayerList widget toe, zodat men de laag aan en uit kan zetten. De volledige code staat hieronder. Klik hier om het eindresultaat in werking te zien. <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Aan de slag met ArcGIS JavaScript - FeatureLayer toevoegen</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.11/esri/css/main.css">
<script src="https://js.arcgis.com/4.11/"></script>
<script>
require([
"esri/Map",
"esri/geometry/Point",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/widgets/LayerList"
], function(Map, Point, MapView, FeatureLayer, LayerList) {
var map = new Map({
basemap: {
portalItem: {
id: "7aea6fa913a94176a1074edb40690318" // Topo RD
}
}
});
var popupTemplate = { // autocasts as new PopupTemplate()
title: "Gemeente {Gemeentenaam}",
content: "Gemeentecode {GM_Code}"
};
var renderer = {
type: "simple", // autocasts as new SimpleRenderer()
symbol: {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
style: "none", // The polygon has no fill
outline: { // autocasts as new SimpleLineSymbol()
width: 1.5,
color: "#F5B041" // Hex Color Code
}
}
};
var nederlandseGemeentenLayer = new FeatureLayer({
url: "https://services.arcgis.com/nSZVuSZjHpEZZbRo/arcgis/rest/services/Bestuurlijke_Grenzen_Gemeenten_2019/FeatureServer/0",
title: "Gemeenten (2019)",
popupTemplate: popupTemplate,
renderer: renderer
});
map.add(nederlandseGemeentenLayer);
var view = new MapView({
spatialReference: 28992,
container: "viewDiv",
map: map,
center: new Point({x: 155000, y: 463000, spatialReference: 28992}),
zoom: 3
});
var layerList = new LayerList({
view: view
});
view.ui.add(layerList, {
position: "top-right"
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
06-19-2019
06:20 AM
|
0
|
0
|
584
|
|
POST
|
Hi Todd Fagin, You might have a look in the Living Atlas of the World. There is a dataset (in the Exclusive content for subscribers) called USA Roads. This Map Image Layer by Esri displays roads from 2014 U.S. Census TIGER dataset. Maybe this will suit your needs? BTW - If you think your original question has been answered, you might mark it as such. In this way we help the Esri Community to find correct answers. Cheers, Egge-Jan
... View more
06-18-2019
06:03 AM
|
1
|
1
|
3248
|
|
POST
|
Hi Todd Fagin, The explanation is quite straightforward, I think. Your cities layer (i.e. the example that works) comes from this sample server USA (MapServer) and has no visibility range set. Both Min Scale and Max Scale are set to 0 ("minScale": 0, "maxScale": 0), thus allowing you to set these values in your JavaScript application. The TIGERweb/Transportation data comes from this server TIGERweb/Transportation (MapServer) and as you can see each and every layer has it's own visibility range set. The different road types (Primary, Secondary and Local Roads) are even offered multiple times, for different visibility ranges. And in this case your options to manipulate (or set) the visibility are much more limited. (Of course you can limit the visibility within it's visibility range, but you cannot extend it outside this range.) So, even though your JavaScript code says the layer should be visible, the TIGERweb server will not return anything to show... I would suggest to add the TIGERweb/Transportation data as a TileLayer instead, like this: var transportation = new TileLayer({
url: "https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Transportation/MapServer"
});
In this way all layers will be added to the map and and automatically adhere to the visibility range settings on the server. Hope this helps to solve your issue. Cheers, Egge-Jan
... View more
06-18-2019
05:13 AM
|
1
|
3
|
3248
|
|
POST
|
Hi Herman Groeneveld, Please have a look at the local variables to set. If you want to retrieve - say - the postal code polygons for the year 2017, you should not only change the variable WFS_Service, but also WFS_FeatureType (and of course Out_Name, to avoid overwriting previous output...) When you have a look at the XML returned by the GetCapabilities request for the postal code polygons, you will see a FeatureTypeList with 3 FeatureTypes: polygons for the years 2015 (postcode42015), 2016 (postcode42016) and 2017 (postcode42017). Below you will find the Python script to retrieve all postal code polygons for the year 2017 (4,066 of them) - and yes, like you say, it works like a charm 🙂 BTW - if you consider one or more of the sub answers useful ("Nuttig"), please do not hesitate to mark them as such. GeoNet likes this kind of feedback. And GeoNet would also like to know whether your initial question has been answered - in this way we can help the Esri Community to find useful and correct answers. And of course, you are always welcome to post new questions on this great learning resource. Or, equally useful: to post answers to questions posted by others...! HTH, Egge-Jan ...
<FeatureTypeList>
...
<FeatureType>
<Name>cbspostcode4:postcode42017</Name>
<Title>Postcode 2017, numeriek deel</Title>
<Abstract>
Gegevens per numeriek deel van de postcode voor het jaar 2017
</Abstract>
... # Name: WFSToFeatureClass_example1.py
# Description: Create a feature class from a WFS service
# Import arcpy module
import arcpy
# Set local variables
WFS_Service = "https://geodata.nationaalgeoregister.nl/cbspostcode4/wfs?&request=GetCapabilities&service=wfs"
WFS_FeatureType = "postcode42017"
Out_Location = "C:/Data/output.gdb"
Out_Name = "postcode42017"
# Execute the WFSToFeatureClass tool
arcpy.WFSToFeatureClass_conversion(WFS_Service, WFS_FeatureType, Out_Location, Out_Name)
... View more
06-17-2019
04:28 AM
|
1
|
1
|
4376
|
|
POST
|
Hi Stacie T., Of course you can! The moment you have these values (i.e. lon and lat) you can do anything you want with them... 🙂 I have modified the code above by adding a line (line 92), to show the values in the "instruction" div: document.getElementById("instruction").innerHTML = "Lon: " + lon + " / Lat: " + lat; Is this what you need? Egge-Jan
... View more
06-17-2019
02:41 AM
|
1
|
2
|
13029
|
|
POST
|
Hi Stacie, What do you think about the code below? I modified this sample to make your map clickable: Intro to popups | ArcGIS API for JavaScript 4.11 When you click in your map you will not only retrieve the coordinates but also an address (when available). Please let me know what you think 🙂 Cheers, Egge-Jan <html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>ArcGIS JavaScript Tutorials: click on the map</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#instruction {
padding: 15px;
background: white;
color: black;
border: 5px solid gold;
font-family: sans-serif;
font-size: 1.2em;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.11/esri/css/main.css">
<script src="https://js.arcgis.com/4.11/"></script>
<script>
require([
"esri/tasks/Locator",
"esri/Map",
"esri/views/MapView",
"esri/Graphic"
], function(Locator, Map, MapView, Graphic) {
// Set up a locator task using the world geocoding service
var locatorTask = new Locator({
url:
"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
});
var map = new Map({
basemap: "topo-vector"
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [110.36402943937549,1.5128959885365645], // longitude, latitude
zoom: 18
});
view.ui.add("instruction", "bottom-left");
var point = {
type: "point",
longitude: 110.36402943937549,
latitude: 1.5128959885365645
};
var simpleMarkerSymbol = {
type: "simple-marker",
color: [226, 119, 40], // orange
outline: {
color: [255, 255, 255], // white
width: 1
}
};
var pointGraphic = new Graphic({
geometry: point,
symbol: simpleMarkerSymbol
});
view.graphics.add(pointGraphic);
/*******************************************************************
* This click event sets generic content on the popup not tied to
* a layer, graphic, or popupTemplate. The location of the point is
* used as input to a reverse geocode method and the resulting
* address is printed to the popup content.
*******************************************************************/
view.popup.autoOpenEnabled = false;
view.on("click", function(event) {
// Get the coordinates of the click on the view
var lat = Math.round(event.mapPoint.latitude * 1000) / 1000;
var lon = Math.round(event.mapPoint.longitude * 1000) / 1000;
view.popup.open({
// Set the popup's title to the coordinates of the location
title: "Reverse geocode: [" + lon + ", " + lat + "]",
location: event.mapPoint // Set the location of the popup to the clicked location
});
document.getElementById("instruction").innerHTML = "Lon: " + lon + " / Lat: " + lat;
// Display the popup
// Execute a reverse geocode using the clicked location
locatorTask
.locationToAddress(event.mapPoint)
.then(function(response) {
// If an address is successfully found, show it in the popup's content
view.popup.content = response.address;
})
.catch(function(error) {
// If the promise fails and no result is found, show a generic message
view.popup.content = "No address was found for this location";
});
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<div id="instruction">
Click on the map to retrieve coordinates and address
</div>
</body>
</html>
... View more
06-17-2019
01:50 AM
|
2
|
4
|
13029
|
|
POST
|
Hi Herman Groeneveld, Did you have a look at this one: WFS To Feature Class—Conversion toolbox | ArcGIS Desktop ? (I am not working for Esri Nederland though 🙂 If we translate the Code Sample from that page to a Dutch example - let's take the Dutch National Parks, my favorite dataset from PDOK - we get something like this: # Name: WFSToFeatureClass_example1.py
# Description: Create a feature class from a WFS service
# Import arcpy module
import arcpy
# Set local variables
WFS_Service = "https://geodata.nationaalgeoregister.nl/nationaleparken/wfs?request=GetCapabilities&service=wfs"
WFS_FeatureType = "nationaleparken"
Out_Location = "C:/Data/output.gdb"
Out_Name = "Nationale_Parken"
# Execute the WFSToFeatureClass tool
arcpy.WFSToFeatureClass_conversion(WFS_Service, WFS_FeatureType, Out_Location, Out_Name) This will get you all the National Parks in the Netherlands, including the newly created park Nieuw Land - see screen capture below. HTH, Egge-Jan
... View more
06-16-2019
12:19 PM
|
1
|
0
|
4376
|
|
POST
|
Hi Herman Groeneveld I think it is the output format that is wrong; I suppose this FeatureSet expects input in Esri JSON format, not in the GeoJSON format from the BAG WFS service from nationaalgeoregister. But did you know that Esri Nederland also serves the official Dutch BAG data via ArcGIS Online? See this page: BAG - Basisregistratie Adressen en Gebouwen You can query the Adres layer from this service via this page: Query: Adres (ID: 0) So following the same pattern as the answer you got from Esri Nederland in another thread (Make Arcpy use Esri Feature Service) you can retrieve address points for a Dutch postal code (e.g. 3524WL) like this: import arcpy
# Query URL opbouwen op basis van bepaalde postcode
ppc = '3524WL'
url = 'https://basisregistraties.arcgisonline.nl/arcgis/rest/services/BAG/BAGv2/MapServer/0/query?where=postcode+%3D+%27{}%27&outFields=*&returnGeometry=true&f=pjson'.format(ppc)
# Omzetten van query naar feature class
fs = arcpy.FeatureSet()
fs.load(url)
fs.save(r'C:\Data\output.gdb\PPC6_{}'.format(ppc))
print ("Klaar") Hope this helps, Egge-Jan
... View more
06-16-2019
11:16 AM
|
1
|
0
|
4376
|
|
POST
|
The issue might be caused by the two backslashes in the filename: C:/Users/user/pictures/pics/\\HGC-2.jpg You should try to find out where these come from.
... View more
06-14-2019
09:48 AM
|
1
|
0
|
1965
|
|
POST
|
Hi Marco Pretorius, The quickest solution would be to replace all backward slashes in your directory paths to forward ones. So 'C:\users\user\Test2\pictures.gdb\pictures__ATTACH' should become 'C:/users/user/Test2/pictures.gdb/pictures__ATTACH', etcetera. And then save and run the script again 🙂 Does this solve your issue? Cheers, Egge-Jan
... View more
06-14-2019
07:55 AM
|
0
|
2
|
1965
|
|
POST
|
Hi Alex Gilvarry, Please have a look at the script below. I use this to publish data (Feature Classes in a zipped File Geodatabase) and populate all the metadata at once. In this way I have a very high Item Information score immediately after publishing 🙂 The input should be: The path to the zip file containing the input File Geodatabase E.g. data = 'C:/Data/MY_NEW_FGDB.gdb.zip' The path to a thumbnail file (a 600*400 pixels PNG file) for your service E.g. service_thumbnail_path = 'C:/Data/Thumbnail_test.png' All the metadata information can be configured in the script file below What do you think? HTH, Egge-Jan ## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Script: agol_publish_fc_from_fgdb_to_featureserver_layer.py
## Goal: to publish a Feature Class from a File Geodatabase to a FeatureServer Layer
## Author: Egge-Jan Polle - Tensing GIS Consultancy
## Date: April 3, 2019
## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# This script should be run within a specific ArcGIS/Python environment using the batch file below
# (This batch file comes with the installation of ArcGIS Pro)
# "C:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" agol_publish_fc_from_fgdb_to_featureserver_layer.py
#
import os, datetime
from arcgis.gis import GIS
from provide_credentials import provide_credentials
# Variables to complete before publishing the service =====================================================================================
# data - The path to the zip file containing the input File Geodatabase
# E.g.'C:/Data/MY_NEW_FGDB.gdb.zip'
data = ''
# service_name - The name of the FeatureServer
# E.g. 'MY_VERY_FIRST_FEATURE_SERVER'
service_name = 'MY_VERY_FIRST_FEATURE_SERVER_TEST'
# service_description - Description of the item. In the Dutch interface: "Beschrijving"
# E.g. 'Here you can put a description of the Feature Layer'
service_description = 'Here you can put a description of the Feature Layer'
# service_snippet - Provide a short summary (limit to max 250 characters) of the what the item is.
# E.g. 'Here you can put a short snippet describing the Feature Layer'
service_snippet = 'Here you can put a short snippet describing the Feature Layer'
# service_terms_of_use - Any license information or restrictions regarding the content. In the Dutch interface: "Gebruiksvoorwaarden"
# E.g. 'FOR INTERNAL USE ONLY'
service_terms_of_use = 'FOR INTERNAL USE ONLY'
# service_credits - Information on the source of the content. In the Dutch interface: "Credits (toeschrijving)"
# E.g. '© Me, myself and I'
service_credits = '© Me, myself and I'
# service_tags - Tags listed as comma-separated values, or a list of strings. Used for searches on items. In the Dutch interface: "Labels"
# E.g. ['INSPIRE','Open Data']
service_tags = ['INSPIRE','Open Data']
# service_wkid - To set the targetSR to the SR of your input data.
# If you don't specify the targetSR data will be transformed to wkid 102100 (-> wkid 3857 -> Web Mercator)
# E.g. 28992 (i.e. RD_New)
service_wkid = 28992
# service_thumbnail_path - The path to a thumbnail file (a 600*400 pixels PNG file) for your service
# E.g.'C:/Data/Thumbnail_test.png'
service_thumbnail_path = ''
# =========================================================================================================================================
print('===================')
print(str(datetime.datetime.now()) + ' - Start')
print('First you have to log in to ArcGIS Online')
# Log in
username, password = provide_credentials()
my_agol = GIS("https://www.arcgis.com", username, password)
del password # It is best to remove the password from memory asap
# Add input File Geodatabase
filegdb = my_agol.content.add({"type" : "File Geodatabase"}, data)
print(str(datetime.datetime.now()) + " - Input FGDB has been added to content on ArcGIS Online")
wait = input("Optionally: check your content - PRESS ENTER TO CONTINUE")
# Publish the FeatureServer
srv_publish_parameters = {'name' : service_name,
'description' : service_description,
'copyrightText' : service_credits,
'targetSR' : { 'wkid' : service_wkid }}
published_service = filegdb.publish(publish_parameters=srv_publish_parameters)
item_id = published_service.id
print(str(datetime.datetime.now()) + " - Service has been published on ArcGIS Online")
print(str(datetime.datetime.now()) + " - The ItemID of the new service is: {}".format(item_id))
wait = input("Optionally: check your content - PRESS ENTER TO CONTINUE")
# Update description of the service item
item_properties = {'snippet' : service_snippet,
'title' : service_name,
'description' : service_description,
'licenseInfo' : service_terms_of_use,
'accessInformation' : service_credits,
'tags' : service_tags}
if published_service.update(item_properties, thumbnail=service_thumbnail_path):
print(str(datetime.datetime.now()) + " - The item properties and the thumbnail of the published service have been updated")
wait = input("Optionally: check your content - PRESS ENTER TO CONTINUE")
# Remove the input File Geodatabase from ArcGIS Online (as it is no longer needed)
if my_agol.content.delete_items([filegdb]):
print(str(datetime.datetime.now()) + " - The input FGDB has been deleted from the content on ArcGIS Online")
print('===================')
print(str(datetime.datetime.now()) + " - Your Feature Layer has been published")
print('===================') provide_credentials.py: import json, os
from getpass import getpass #to accept passwords in an interactive fashion
def provide_credentials():
file_with_credentials = 'my_credentials.json'
username = ''
password = ''
if os.path.exists(file_with_credentials):
with open(file_with_credentials) as f:
data = json.load(f)
username = data['username']
password = data['password']
if not username or username == 'USERNAME' or not password or password == 'PASSWORD':
username = input('Please enter your username: ')
password = getpass('Please enter your password (this will remain invisible): ')
return username, password my_credentials.json: {
"username":"USERNAME",
"password":"PASSWORD"
}
... View more
06-12-2019
08:15 AM
|
1
|
0
|
1823
|
|
POST
|
OK - just let us know whether the patch solves the issue. And if it is solved, you can mark this question as being answered. E-J
... View more
06-12-2019
07:52 AM
|
0
|
2
|
2025
|
|
POST
|
Hi Shukwaun Cheung, You might have a look at a Python script which I have published here: https://community.esri.com/people/EPolle_TensingInternational/blog/2019/03/21/a-quick-overview-of-group-membership-in-your-agol-organization Does this serve your purposes? Cheers, Egge-Jan
... View more
06-12-2019
06:49 AM
|
2
|
3
|
2451
|
|
POST
|
Hi Sofi Johansson, Same for me: url works fine and I was able to calculate a route (see screen capture below). Did you find the reason of your error already? Cheers, Egge-Jan
... View more
06-12-2019
06:17 AM
|
1
|
0
|
2809
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-11-2019 08:58 AM | |
| 1 | 03-30-2020 09:03 AM | |
| 2 | 12-12-2024 03:56 AM | |
| 2 | 04-15-2024 03:25 AM | |
| 2 | 03-25-2024 02:06 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-19-2025
02:25 AM
|