|
POST
|
Hi, I just want to point out the Consolidate Map tool that exports the contents of a map document. There are some more Consolidate <Something> tools available. It does not give you as fine control as you can achieve in Python if you wanted to exclude some layers for example, but it can be pretty useful still. Cheers, F.
... View more
08-29-2014
08:23 AM
|
1
|
0
|
1797
|
|
POST
|
Hi Robert, yep, I know, yet even that is awkward. It is also what I am doing now : feature.geometry.spatialReference = map.spatialReference; But if you allow users to add whatever service they like into the application, you don't want to make the assumption that the features you are getting are in the map's spatialReference. I guess I could check the service they add for spatial reference and set it from there, but there may be a point where you simply get some features from somewhere who knows where. It would be nice if the spatialReference was correct. Thanks anyway. Filip.
... View more
08-27-2014
10:02 AM
|
0
|
0
|
1431
|
|
POST
|
Oh my! I am experiencing this too! I tried to step down from JS API 3.10 to 3.7 but they all had the same issue and my app stopped working with <3.7. Services from ArcGIS for Server 10.2.2. Interestingly, the the identifyTask seemed to work with points fine, but polygons came back with the right coordinate values, but with spatialReference 4326. Regardless of relevant settings in IdentifyParameters. Another strange thing is that the REST interface seems to return the correct spatialReference if I use the HTML interface of that service. Re-setting the spatial reference is not an option for real use and projecting each feature (IdentifyTask + InfoWindow 'Zoomto' button using wrong spatial reference)is not only demanding, but it wouldn't work because the coordinates are fine, just the spatial reference is wrong. Please share any news about this topic! Filip.
... View more
08-27-2014
08:50 AM
|
0
|
2
|
1431
|
|
POST
|
Today I came across Dojo--The-Good-Parts by David Spriggs. It is a very clear yet brief overview of some key elements of dojo. I wish more texts about dojo were as clear and to the point as this one. David's intro is in context of ArcGIS JS API, which is another plus. If you know about similarly concise resources for dojo, please share. Cheers, Filip.
... View more
08-19-2014
01:37 PM
|
0
|
1
|
969
|
|
POST
|
Glad I could help. I used a lot of Bootstrap components. There is a lot of room for improvements. For example the content of the left tab is hard-coded to some extent (like the tabs you showed), then some components within that are more widget-like, but not entirely ready at this point. I am still working on it (on and off), trying to combine dojo and jquery. F.
... View more
08-19-2014
01:00 PM
|
1
|
1
|
1886
|
|
POST
|
Hi, thanks, As far as I know, you can resize the map simply by calling map.resize(); when appropriate. In most browsers you should be able to press Ctrl+U to display the source code of the page, search in there for 'resize()', like on row 2233. If Ctrl+U doesn't work for you, try something like Tools -> Developer -> View source code of your browser (or something like that). F.
... View more
08-19-2014
12:34 PM
|
0
|
3
|
1886
|
|
POST
|
Hi, It is certainly possible, although I am not sure if you can have intermediate output as a parameter of a geoprocessing service like the Multipatch Feature Class in your model. I guess it is important to make the distinction between input and output parameters. I'd recommend adding Copy Features or Feature Class To Feature Class tool to copy the Multipatch Feature Class into say Multipatch Output, and making the Multipatch Output a Parameter instead of the Multipatch Feature Class (wchich will reside in some scratch workspace). Similarly, you are missing arcpy.SetParameter in your python script to tell ArcGIS what to use as output from the script. Hope this helps. Filip
... View more
08-19-2014
12:28 PM
|
0
|
3
|
1225
|
|
POST
|
Hi, Are you resizing the map after each layout pane is resized? Look at row 2233 of this demo (a bit messy, you may need to refresh couple of times). http://wlwater.ceh.ac.uk/lwis/apps/cc-impacts/ Cheers, Filip.
... View more
08-19-2014
12:13 PM
|
0
|
2
|
1886
|
|
POST
|
Wow, that's a pretty cool dataset. The text file didn't have a proper header so it requires a bit more manipulation. If the header was just a single row with column names, it would be easier. The code below converts the input text file into a feature class with only the surface nitrate, the deepest non-zero nitrate, and the depth of the deepest non-zero nitrate value. Everything including the resulting shapefile is in the attached folder. Hopefully the comments in the code will help you understand what it does. A good way to play with it is to run it row by row (block by block) in something like PyScripter
import arcpy
import os
csv = r'C:\Nitrate_GridP_Annual\Nitrate_GridP_Annual.csv'
out_fc = r'C:\Nitrate_GridP_Annual\ni.shp'
# read the csv into memeory
rows = []
with open(csv, 'r') as f:
for row in f:
rows.append(row.strip())
# The first two rows are not very useful so let's drop them
rows.pop(0) # drop the first row
depths = rows.pop(0) # drop the second row, which is now the first one
depths = map(int, depths[depths.find(':')+1:].split(','))
# Get lat, lon, Nitrate near the surface, and last non-zero measurement
newrows = []
for row in rows:
rowdata = map(float, row.split(','))
lat, lon = rowdata[0], rowdata[1]
nitrate = rowdata[2:]
n_near_surface = nitrate.pop(0) # first is near the surface
# get the deepest non-zero value and its depth
n_deepest = 0.0
depth = 0
i = 0
for i in range(len(nitrate)):
n = nitrate
if n > 0:
n_deepest = n
d = depths[i+1]
newrow = [lat, lon, n_near_surface, n_deepest, d]
newrows.append(newrow)
# write output to feature class
out_path, out_name = os.path.split(out_fc)
sr = arcpy.SpatialReference(4326) # define coordinate system (WGS84)
fc = arcpy.management.CreateFeatureclass(out_path, out_name, "POINT", spatial_reference=sr).getOutput(0)
arcpy.management.AddField(fc, "N_0", "DOUBLE")
arcpy.management.AddField(fc, "N_DEEP", "DOUBLE")
arcpy.management.AddField(fc, "DEPTH", "DOUBLE")
with arcpy.da.InsertCursor(fc, ["SHAPE@", "N_0", "N_DEEP", "DEPTH"]) as ic:
for row in newrows:
pt = arcpy.Point(row[1], row[0]) # remember that lon is x, lat is y
newrow = [pt, row[2], row[3], row[4]]
ic.insertRow(newrow)
del row
del ic
print fc
Please check that the outputs are correct! I rushed a bit while writing this. Hope this helps, Filip.
... View more
08-19-2014
05:26 AM
|
3
|
1
|
4935
|
|
POST
|
Hi Joshua, I'd say creating a polygon from a map click is certainly possible, but technicalities may be a bit different in ArcMap and the APIs. When a user clickes a map, the map emits an on-click event. One of the properties of the parameter passed into the event handler is the point that was clicked. Take that point and calculate where the vertices of your polygon (like Darren suggested). I believe a map SilverLight (similarly to JavaScript) has one (or more) graphics layer(s), ideal for storing and displaying temporary geometries. Once you have your polygon, add it to the graphics layer. Paste the code below into ArcGIS API for JavaScript Sandbox . Is it roughly what you want to do?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Polygon from map click</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; }
body { background-color: #FFF; overflow: hidden; font-family: "Trebuchet MS"; }
#help {position: absolute; top: 20px; right: 20px; z-index: 1001; background-color: white; padding: 10px;}
</style>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map;
require(["esri/map", "esri/graphic",
"esri/geometry/webMercatorUtils",
"esri/geometry/Polygon",
"esri/symbols/SimpleFillSymbol",
"dojo/on","dojo/domReady!"
], function(Map, Graphic, webMercatorUtils, Polygon, SimpleFillSymbol) {
map = new Map("map", { basemap: "topo",center: [-92.0, 35.0], zoom: 9 });
var symbol = new SimpleFillSymbol({
"type": "esriSFS", "style": "esriSFSSolid", "color": [255,0,0,100],
"outline": {"type": "esriSLS", "style": "esriSLSSolid", "color": [255,0,0,255],"width": 1}
});
map.on('click', function(evt){
var pt = evt.mapPoint;
var x = pt.x, y = pt.y;
var dx = 500, dy = 1000; // THESE ARE JUST WEB MERKATOR UNITS NOW, NOT METRES!!!
var polygon = new Polygon({"rings":[[
[x - dx, y - dy], [x - dx, y + dy],
[x + dx, y + dy], [x + dx, y - dy], [x - dx, y - dy]
]], "spatialReference": pt.spatialReference});
//var pgwgs = webMercatorUtils.webMercatorToGeographic(polygon); // might come handy
var gr = new Graphic(polygon, symbol);
map.graphics.clear(); // may need to remove just a particular graphic
map.graphics.add(gr);
});
});
</script>
</head>
<body>
<div id="help">Click on the map to create a polygon</div>
<div id="map"></div>
</body>
</html>
I won't get into details about handling different coordinate systems now, maybe when we know what you are after. Also, you could potentially buffer the point and get envelope of the buffer to get a rectangle which you could then adjust. At what scale are you working? When I set the size to 10x20, the polygon wasn't even visible unless I zoomed really close. Filip.
... View more
08-18-2014
04:14 PM
|
1
|
3
|
2767
|
|
POST
|
Hmm, I cannot see anything obviously wrong with your code so it might be something about your data. Did you verify that your longValue and latValue variables contain what you would expect for example using a print statement? Below is your code where the inserting uses the InsertCursor in the data access module (but haven't tested it). If you have ArcGIS 10.1 and above, try it. Filip.
import arcpy
arcpy.env.overwriteOutput = True
out_path = r"M:\work\nettoc\MAS201300311\PythonModule\import_data"
pointFC = r"M:\work\nettoc\MAS201300311\PythonModule\import_data\POI.shp"
geoType = "POINT"
StructurePoints = open(r"M:\work\nettoc\MAS201300311\PythonModule\import_data\TEST2.txt", "r")
coordList = []
# Parse the exported text file and create a list that Python can read
# figure out position of the lat and long in the header
headerLine = StructurePoints.readline()
valueList = headerLine.split(",")
latValueIndex = valueList.index('"SURF_LATITUDE"')
longValueIndex = valueList.index('"SURF_LONGITUDE"')
planValueIndex = valueList.index('"PLAN"')
typeValueIndex = valueList.index('"PLAN_SITE_TYPE"')
ancRadiusValueIndex = valueList.index('"ANCHOR_RADIUS"')
# Read line in the file and append to coordinate list
for line in StructurePoints.readlines():
# need to say what the seperating value is, in this case its the ","
segmentedLine = line.split(",")
# only append the value (index) indicated... we could have used "segmentedline[2]", but if lat changes position in the header list
# we would have to change the index number.
coordList.append([segmentedLine[planValueIndex], segmentedLine[typeValueIndex], segmentedLine[ancRadiusValueIndex], segmentedLine[longValueIndex], segmentedLine[latValueIndex]])
# Loop and delete any existing features in the shapefile
rows = arcpy.UpdateCursor(pointFC)
for row in rows:
rows.deleteRow(row)
del rows, row
print "Prepairing shape file..."
# Loop through new created coordlist and insert the the points in the existing shape file
with arcpy.da.InsertCursor(pointFC, ["SHAPE@", "DESCR", "ANCHOR_RAD"]) as rowInserter:
#Loop through each coordinate in the list
for coordinate in coordList:
# Grab a set of coordinates from the list and assign them to a point obejct
longValue = float(coordinate[3])
latValue = float(coordinate[4])
pointGeometry = arcpy.Point(longValue,latValue)
descr = coordinate[0] + ", " + coordinate[1]
andchor_rad = coordinate[2]
newrow = [pointGeometry, descr, anchor_rad]
rowInserter.insertRow(newrow)
del rowInserter
print "The following points were created"
print coordList
... View more
08-18-2014
09:28 AM
|
0
|
2
|
1947
|
|
POST
|
Hi, You might be able to do what you need with SummaryStatistics_analysis, but SearchCursor might be easier. However, from your description I am not entirely sure how do you imagine your result. Can you paste some code you have in here? Or show us how the table looks exactly? (when pasting code, use the advanced editor and apply syntax highlighting on the code '>> -> Syntax Highlighting -> python') I am guessing you can get what you are after if you use the sql_clause parameter of the SearchCursor to order your rows. Cheers, Filip.
... View more
08-18-2014
07:07 AM
|
0
|
6
|
4935
|
|
POST
|
Hi Rene, I marked your answer as correct because I also found that the use of deferreds is the only way to ensure that a block of code is executed only after some other block of code has finished. As you indicated, the def.resolve(sb) on your line 12 should be more like sb.on('load', function(){ def.resolve(sb); });, if only the widget emitted a load event when ready. When I originally asked the question, I was hoping for a more simple answer. I find this way of coding rather verbose and confusing, especially if you want to wait for multiple asynchronous calls and make them all play together. Quite a few examples show use of deferrds in basic scenarios but I cannot find a nice guide to structuring JavaScript code in larger applications. If you know about a good resource for this, please share. Thank you all for contributions, Filip
... View more
08-13-2014
02:47 PM
|
0
|
0
|
533
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-05-2014 04:40 AM | |
| 1 | 02-08-2015 12:49 PM | |
| 1 | 07-20-2014 12:41 PM | |
| 1 | 03-23-2017 01:48 PM | |
| 1 | 08-18-2014 04:14 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|