Displaying more than one (x,y) point,

4816
9
Jump to solution
02-22-2013 10:00 PM
JamalNUMAN
Legendary Contributor
Displaying more than one (x,y) point,

One of the very powerful tool to get information at a particular location is to have its xy coordinates and then to go to it.

In certain cases, providing one point is not sufficient particularly if the information is required for an area (polygon)! In this case we need to provide more points to better represent the boundary of that area.

[ATTACH=CONFIG]22108[/ATTACH]

Such tool is not built in the ???ArcGIS Viewer for Silverlight???! And if it is there as add-ins it is not as powerful as the one in the ArcGIS Desktop


1. ???ArcGIS Viewer for Silverlight??? doesn???t recognize the coordinate system of the operational layer as the ???ArcGIS Web ADF??? does.

[ATTACH=CONFIG]22109[/ATTACH]

2. The tool will never include functions the ???add callout??? and ???add labeled point???

[ATTACH=CONFIG]22110[/ATTACH]

3. The other issue is that the ???go to xy??? is not a tool on the ArcGIS so that it can be published!

[ATTACH=CONFIG]22111[/ATTACH]

What might be the solution then to have such tool?


Thank you

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: ipeebles

Jamal,

Try this script that I have attached.  The zip file contains the following contents:

1. outputworkspace (folder used for scratch)
2. Script (folder that contains the XY.py script)
3. Symbology (folder that contains the output symbology as layer files)
4. Toolbox.tbx (contains the FindCoordinate script tool)

The script contains a creation of an event layer that uses your coordinate system.

Steps to follow:
1. Copy these files into a folder to your local drive or server.  You might name it Coordinates.
2. Set the scratch workspace in your .mxd.  In this case, I used: C:\Files\GIS\Coordinates\outputworkspace (Geoprocessing -- Environment -- Workspace -- Scratch Workspace)
3. Open the Toolbox and run the tool.
4. Enter in the coordinate and click OK.  Takes about 1 second to run.
5. The results will appear in the table of contents, symbolized with the coordinates labeled based on the referenced layer file.
6. If the script successfully runs, in ArcMap go to: Geoprocessing -- Results -- Current Session.
7. Right Click on the last geoprocessing results and choose Share as Geoprocessing Service.
8. Following the publishing of your geoprocessing service, you can add this into your silverlight application as a tool.

I hope this helps.  Below is a screenshot of what the geoprocessing results look like after it is run in ArcMap.

View solution in original post

0 Kudos
9 Replies
IanPeebles
Occasional Contributor III
Jamal,

I had the same issue, but built a python script and use it as a tool in the application builder.  The tool will add coordinates to the map.  The results will show up in the table of contents and you can use the zoom to layer to zoom in on the coordinates.  You can perform multiple searches.  Below is the full code for the tool if you are interested.

----------------------------------------------

# Import arcpy module
import arcpy, os, sys
from arcpy import env

# Set Geoprocessing environments
scratch = arcpy.env.scratchWorkspace
arcpy.env.scratchWorkspace = r"E:\geoprocessing\FindCoordinates\outputworkspace"
arcpy.env.overwriteOutput = True

# Process: Create Table
FindCoordinatesTable = os.path.join(scratch,'FindCoordinates.dbf')
arcpy.CreateTable_management(scratch, "FindCoordinates.dbf", "", "")
arcpy.AddField_management(FindCoordinatesTable, "X", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.AddField_management(FindCoordinatesTable, "Y", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

# Coordinate Input Parameters
XCoordinate = arcpy.GetParameterAsText(0)
YCoordinate = arcpy.GetParameterAsText(1)

# Create Insert Cursor and a New Empty Row
rowInserter = arcpy.InsertCursor(FindCoordinatesTable)
NewRecord = rowInserter.newRow()

# Populate Attributes of New Row
NewRecord.X = XCoordinate
NewRecord.Y = YCoordinate

# Insert New Row Into Table
rowInserter.insertRow(NewRecord)

# Local variables:
FindCoordinatesLayer = "FindCoordinatesLayer"
FeatureToPointSHP = os.path.join(scratch,'FeatureToPoint.shp')
FindCoordinateSHP = os.path.join(scratch,'FindCoordinate.shp')
FindCoordinatesBuffer = os.path.join(scratch,'FindCoordinatesBuffer.shp')

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(FindCoordinatesTable, "x", "y", FindCoordinatesLayer, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433],METADATA['World',-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1262]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision", "")

# Process: Feature To Point
arcpy.FeatureToPoint_management(FindCoordinatesLayer, FeatureToPointSHP, "CENTROID")

# Process: Project
arcpy.Project_management(FeatureToPointSHP, FindCoordinateSHP, "PROJCS['NAD_1983_StatePlane_Oklahoma_North_FIPS_3501_Feet',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',1968500.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-98.0],PARAMETER['Standard_Parallel_1',35.56666666666667],PARAMETER['Standard_Parallel_2',36.76666666666667],PARAMETER['Latitude_Of_Origin',35.0],UNIT['Foot_US',0.3048006096012192]]", "WGS_1984_(ITRF00)_To_NAD_1983", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433],METADATA['World',-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1262]]")

# Coordinate Buffer
arcpy.Buffer_analysis(FindCoordinateSHP, FindCoordinatesBuffer, "75 Feet", "FULL", "ROUND", "NONE", "")
arcpy.AddMessage("Coordinates mapped.")

# Output Parameters
arcpy.SetParameterAsText(2,FindCoordinateSHP)
arcpy.SetParameterAsText(3,FindCoordinatesBuffer)

----------------------------------
Set tool Parameters:

Find X Coordinate (Long)           Double
Find Y Coordinate (Lat)             Double
Coordinate Output                   Shapefie  Type: Derived; Direction: Output; Environment: ScratchWorkspace; Symbology (specify layer file)
Coordinate Output Buffer          Shapefie  Type: Derived; Direction: Output; Environment: ScratchWorkspace; Symbology (specify layer file)

-----------------------------------
What it looks like in the application Builder:
0 Kudos
IanPeebles
Occasional Contributor III
I will also point out that the data in the application is in state plane coordinates (feet), so I had to reproject the intermediate data to WGS 1984 to get the coordinates in decimal degrees.  If you are working in WGS 1984, you can eliminate this step.

Also the reason there is a buffer is because you cannot zoom to a point in the application builder. . only lines and polygons.  The buffer is invisible, so only the point shows up.

Seems kind of goofy, but this is how I got it to work.
0 Kudos
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

I will also point out that the data in the application is in state plane coordinates (feet), so I had to reproject the intermediate data to WGS 1984 to get the coordinates in decimal degrees.  If you are working in WGS 1984, you can eliminate this step.

Also the reason there is a buffer is because you cannot zoom to a point in the application builder. . only lines and polygons.  The buffer is invisible, so only the point shows up.

Seems kind of goofy, but this is how I got it to work.



Thank you very much Peebles for the help and sharing the code. This is very useful.

I tried to construct a tool script (attached) and providing x,y coordinate but sounds nothing come up! (Our coordinate system is Palestine grid 1923)

[ATTACH=CONFIG]22192[/ATTACH]


Where might be my mistake?

Best

Jamal
0 Kudos
IanPeebles
Occasional Contributor III
Jamal,

Can you zip up your  source data as a shapefile and re-attach?  You can eliminate the fields you do not want to show.  The .gdb is not working.   I will take a look.
0 Kudos
by Anonymous User
Not applicable
Original User: ipeebles

Jamal,

Try this script that I have attached.  The zip file contains the following contents:

1. outputworkspace (folder used for scratch)
2. Script (folder that contains the XY.py script)
3. Symbology (folder that contains the output symbology as layer files)
4. Toolbox.tbx (contains the FindCoordinate script tool)

The script contains a creation of an event layer that uses your coordinate system.

Steps to follow:
1. Copy these files into a folder to your local drive or server.  You might name it Coordinates.
2. Set the scratch workspace in your .mxd.  In this case, I used: C:\Files\GIS\Coordinates\outputworkspace (Geoprocessing -- Environment -- Workspace -- Scratch Workspace)
3. Open the Toolbox and run the tool.
4. Enter in the coordinate and click OK.  Takes about 1 second to run.
5. The results will appear in the table of contents, symbolized with the coordinates labeled based on the referenced layer file.
6. If the script successfully runs, in ArcMap go to: Geoprocessing -- Results -- Current Session.
7. Right Click on the last geoprocessing results and choose Share as Geoprocessing Service.
8. Following the publishing of your geoprocessing service, you can add this into your silverlight application as a tool.

I hope this helps.  Below is a screenshot of what the geoprocessing results look like after it is run in ArcMap.
0 Kudos
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Jamal,

Try this script that I have attached.  The zip file contains the following contents:

1. outputworkspace (folder used for scratch)
2. Script (folder that contains the XY.py script)
3. Symbology (folder that contains the output symbology as layer files)
4. Toolbox.tbx (contains the FindCoordinate script tool)

The script contains a creation of an event layer that uses your coordinate system.

Steps to follow:
1. Copy these files into a folder to your local drive or server.  You might name it Coordinates.
2. Set the scratch workspace in your .mxd.  In this case, I used: C:\Files\GIS\Coordinates\outputworkspace (Geoprocessing -- Environment -- Workspace -- Scratch Workspace)
3. Open the Toolbox and run the tool.
4. Enter in the coordinate and click OK.  Takes about 1 second to run.
5. The results will appear in the table of contents, symbolized with the coordinates labeled based on the referenced layer file.
6. If the script successfully runs, in ArcMap go to: Geoprocessing -- Results -- Current Session.
7. Right Click on the last geoprocessing results and choose Share as Geoprocessing Service.
8. Following the publishing of your geoprocessing service, you can add this into your silverlight application as a tool.

I hope this helps.  Below is a screenshot of what the geoprocessing results look like after it is run in ArcMap.



Very much appreciated Peebles for the massive help and support.

I followed exactly the valuable steps that you have supplied.

1. It works on the ArcGIS desktop (the data is attached) but it doesn�??t keep more than one point on the map at the same time! As the second point is searched the first one is eliminated!

For example, if I need to know the classification of the a land bounded by the coordinates below, then surely I need to see all of them together at the same time but not one by one. Is that possible with the code?

x Y
165000 160000
165000 165000
175000 160000
175000 165000

[ATTACH=CONFIG]22200[/ATTACH]

2. I expect that it would be quite difficult if this command is enabled by �??add callout�?� the same way it works in the ArcGIS desktop

[ATTACH=CONFIG]22201[/ATTACH]

3. It doesn�??t work on the Silverlight AT ALL. What might be the issue?

[ATTACH=CONFIG]22202[/ATTACH], [ATTACH=CONFIG]22203[/ATTACH]

Best

Jamal
0 Kudos
IanPeebles
Occasional Contributor III
Jamal, it looks like you are getting closer.  You will only be able to see one result at a time in ArcGIS desktop, because the data is overwritten in the scratchworkspace each time you run the tool.  This works as designed.  Now, if you run the script successfully, you should be able to publish a geoprocessing service.

I checked your projection system for your data and it looks fine.  There shouldn't be any issues there.

What I will suggest you do is check your geoprocessing service settings.  Specifically look at the Parameters and look for the View Results with a Map Service.  Make sure the box is checked.  I have this checked and I can see my geoprocessing results for the same tool I built for our organization.

After you check your service, re-run the tool in the application builder.  When you run the tool, the results will appear in the table of contents, then you can zoom to layer using the out of the box tool.  If you run the tool again, another result will appear in the table of contents on top of the other one in the table of contents.  This will give your multiple results that you are wanting.

I think you are close, because you were able to publish the service.  Check your service settings again.
0 Kudos
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Jamal, it looks like you are getting closer.  You will only be able to see one result at a time in ArcGIS desktop, because the data is overwritten in the scratchworkspace each time you run the tool.  This works as designed.  Now, if you run the script successfully, you should be able to publish a geoprocessing service.

I checked your projection system for your data and it looks fine.  There shouldn't be any issues there.

What I will suggest you do is check your geoprocessing service settings.  Specifically look at the Parameters and look for the View Results with a Map Service.  Make sure the box is checked.  I have this checked and I can see my geoprocessing results for the same tool I built for our organization.

After you check your service, re-run the tool in the application builder.  When you run the tool, the results will appear in the table of contents, then you can zoom to layer using the out of the box tool.  If you run the tool again, another result will appear in the table of contents on top of the other one in the table of contents.  This will give your multiple results that you are wanting.

I think you are close, because you were able to publish the service.  Check your service settings again.


Very much appreciated Peebles for the prompt help and elaboration,

1. Sure, the geoprocessing tool is working fine on the ArcGIS desktop (screenshot below)

[ATTACH=CONFIG]22243[/ATTACH]

2. The geoprocessing tool is successfully published (screenshot below)

[ATTACH=CONFIG]22244[/ATTACH]

3. the geoprocessing tool is successful added to the Silverlight but I got the same error as I run it (screenshot below)

[ATTACH=CONFIG]22245[/ATTACH], [ATTACH=CONFIG]22246[/ATTACH]

What other issues that I need to consider and set to let it work?


Best

Jamal
0 Kudos
JamalNUMAN
Legendary Contributor
Jamal, it looks like you are getting closer.  You will only be able to see one result at a time in ArcGIS desktop, because the data is overwritten in the scratchworkspace each time you run the tool.  This works as designed.  Now, if you run the script successfully, you should be able to publish a geoprocessing service.

I checked your projection system for your data and it looks fine.  There shouldn't be any issues there.

What I will suggest you do is check your geoprocessing service settings.  Specifically look at the Parameters and look for the View Results with a Map Service.  Make sure the box is checked.  I have this checked and I can see my geoprocessing results for the same tool I built for our organization.

After you check your service, re-run the tool in the application builder.  When you run the tool, the results will appear in the table of contents, then you can zoom to layer using the out of the box tool.  If you run the tool again, another result will appear in the table of contents on top of the other one in the table of contents.  This will give your multiple results that you are wanting.

I think you are close, because you were able to publish the service.  Check your service settings again.



Hi Ian,

I got a help form Mr. Robert and the issue was related to level of license of my ArcGIS Server.

http://forums.arcgis.com/threads/82268-Python-script-tool-works-in-Desktop-but-fails-in-Web?p=290652...

I managed to get an evaluation license for the ArcGIS Server Advanced and the tool worked like a charm

[ATTACH=CONFIG]24038[/ATTACH], [ATTACH=CONFIG]24039[/ATTACH], [ATTACH=CONFIG]24040[/ATTACH]

Many thanks

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos