|
POST
|
If you are using a FeatureLayer, you can use the queryExtent (FeatureLayer | API Reference | ArcGIS API for JavaScript 3.17 ) or queryFeatures (FeatureLayer | API Reference | ArcGIS API for JavaScript 3.17 ) functions to determine the extent of the features based on an attribute query. Something like: var query = new esri.tasks.Query();
query.where = "TYPE = 'breeding'"
featureLayer.queryExtent(query,function(result){
map.setExtent(result.extent);
})
... View more
08-10-2016
12:46 AM
|
1
|
1
|
822
|
|
POST
|
I found a Python script on StackExchange [Automated/geoprocesing tool to slice, clip, or cut polygons using polylines using ArcGIS Desktop? - Geographic Informati… ] that does the job. Credit to John Tran, Tristan Forward Copy and save the code below to a .py file Create a new script tool in your ArcToolbox for the new py file Set the parameters for the script as: Input Polygon (type Feature Class, direction Input) Input Polyline (type Feature Class, direction Input) Output Polygon (type Feature Class, direction Output) Run the script tool __author__ = "John K. Tran, Tristan Forward" __contact__ = "[email protected], http://gis.stackexchange.com/users/6996/tristan-forward" __version__ = "2.0" __created__ = "7/3/15" __credits__ = "http://gis.stackexchange.com/questions/124198/optimizing-arcpy-code-to-cut-polygon" """ Cut polygons by polylines, splitting each polygon into slices. :param to_cut: The polygon to cut. :param cutter: The polylines that will each polygon. :param out_fc: The output with the split geometry added to it. """ import os import sys import arcpy arcpy.SetProgressor("default", "Firing up script...") to_cut = arcpy.GetParameterAsText(0) cutter = arcpy.GetParameterAsText(1) out_fc = arcpy.GetParameterAsText(2) spatialref = arcpy.Describe(to_cut).spatialReference polygons = [] lines = [] slices = [] gcount = 0 pcount = 0 with arcpy.da.SearchCursor(to_cut, ["SHAPE@", "OID@"]) as pcursor: for prow in pcursor: arcpy.SetProgressorLabel("Generating slices: {0} rows complete".format(str(pcount))) polygon = prow[0] polyid = prow[1] polygons.append((polygon, polyid)) pcount += 1 del pcursor lcount= 0 with arcpy.da.SearchCursor(cutter, ["SHAPE@", "OID@"]) as lcursor: for lrow in lcursor: line = lrow[0] lineid = lrow[1] lines.append((line, lineid)) lcount += 1 del lcursor def cut_geometry(): global polygons global lines global slices global gcount for eachpoly, eachpolyid in polygons: iscut = False for eachline, eachlineid in lines: if eachline.crosses(eachpoly): try: slice1, slice2 = eachpoly.cut(eachline) polygons.insert(0, (slice1, eachpolyid)) polygons.insert(0, (slice2, eachpolyid)) iscut = True except RuntimeError: continue if iscut == False: slices.append((eachpoly, eachpolyid)) gcount += 1 if gcount % 10 == 0: arcpy.SetProgressorLabel("Cutting polygons: {0} rows complete".format(str(gcount))) polygons.remove((eachpoly, eachpolyid)) while polygons: cut_geometry() arcpy.SetProgressorLabel("Creating output feature class") arcpy.CreateFeatureclass_management(os.path.dirname(out_fc), os.path.basename(out_fc), "POLYGON", spatial_reference = spatialref) arcpy.AddField_management(out_fc, "SOURCE_OID", "LONG") scount = 0 with arcpy.da.InsertCursor(out_fc, ["SHAPE@", "SOURCE_OID"]) as icursor: for eachslice in slices: if scount % 10 == 0: arcpy.SetProgressorLabel("Inserting slices: {0} rows complete".format(str(scount))) icursor.insertRow(eachslice) scount += 1 del icursor arcpy.SetProgressorLabel("Deleting duplicate slices") shapefieldname = arcpy.Describe(out_fc).shapeFieldName arcpy.DeleteIdentical_management(out_fc, [shapefieldname, "SOURCE_OID"]) arcpy.ResetProgressor()
... View more
08-09-2016
11:45 PM
|
1
|
0
|
4461
|
|
POST
|
Like I said before, your output basename created after the split creates a list, so you need to access the first item of the list and not the entire list: BaseNameCopy = BaseName.split(".shp")
print BaseNameCopy[0]
arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy[0]))
... View more
08-08-2016
06:56 AM
|
1
|
0
|
1010
|
|
POST
|
Your output basename created after the split creates a list, so you need to access the first item of the list and not the entire list: BaseNameCopy = BaseName.split(".shp")
print BaseNameCopy[0]
arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy[0]))
... View more
08-08-2016
06:36 AM
|
0
|
0
|
2273
|
|
POST
|
Here you go: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
<script src="https://js.arcgis.com/3.17/"></script>
<style>
html, body, #map {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/layers/LabelLayer",
"esri/layers/LabelClass",
"esri/symbols/TextSymbol",
"esri/symbols/Font", "esri/Color",
"dojo/domReady!"
],
function(
Map,
FeatureLayer,
LabelLayer,
LabelClass,
TextSymbol,
Font, Color
) {
map = new Map("map", {
basemap: "hybrid",
center: [-120.33, 47.43],
zoom: 16,
showLabels : true // important!
});
//Add feature layer, first layer listed will be on the bottom...last layer listed will be on top.
//another feature layer
var roads = new FeatureLayer("https://atlas2013.co.chelan.wa.us/arcgis/rest/services/GIS/roads/MapServer/0",{
showLabels : false
});
map.addLayer(roads);
//another feature layer with labels
zoning = new FeatureLayer("https://atlas2013.co.chelan.wa.us/arcgis/rest/services/ChelanCountyGIS/MapServer/20", {
id: "Zoning",
outFields: ["*"],
opacity: 0.7,
showLabels : true
});
//label settings
var zoningLabels = new TextSymbol();
var json = {
"labelExpressionInfo": {
"value": "{Zoning}"
}
};
//instance of labelClass
var lc = new LabelClass(json);
lc.symbol = new TextSymbol({
font: new Font("12", Font.STYLE_NORMAL, Font.VARIANT_NORMAL, Font.WEIGHT_BOLD, "Helvetica"),
color: new Color("#000")
});
zoning.setLabelingInfo([lc]);
map.addLayer(zoning);
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
... View more
08-08-2016
02:06 AM
|
0
|
0
|
825
|
|
POST
|
Sounds like there is a visibility scale range limitation for the labels: Setting scale ranges for label classes—Help | ArcGIS for Desktop
... View more
08-07-2016
10:45 PM
|
1
|
0
|
1105
|
|
POST
|
Here's the better solution: <!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>Layer List Dijit</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.17/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
<style>
html, body, .container, #map {
height:100%;
width:100%;
margin:0;
padding:0;
margin:0;
font-family: "Open Sans";
}
#map {
padding:0;
}
#layerListPane{
width:25%;
}
.esriLayer{
background-color: #fff;
}
.esriLayerList .esriList{
border-top:none;
}
.esriLayerList .esriTitle {
background-color: #fff;
border-bottom:none;
}
.esriLayerList .esriList ul{
background-color: #fff;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="https://js.arcgis.com/3.17/"></script>
<script>
require([
"esri/arcgis/utils",
"esri/dijit/LayerList",
"esri/dijit/LayerSwipe",
"dojo/_base/array",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
], function(
arcgisUtils,
LayerList,LayerSwipe,
array
) {
//Create a map based on an ArcGIS Online web map id
arcgisUtils.createMap("62702544d70648e593bc05d65180fd64", "map").then(function(response){
var id;
var map = response.map;
var title = "2009 Obesity Rates";
var layers = response.itemInfo.itemData.operationalLayers;
array.some(layers, function(layer){
if(layer.title === title){
id = layer.id;
if(layer.featureCollection && layer.featureCollection.layers.length){
id = layer.featureCollection.layers[0].id;
}
return true;
}else{
return false;
}
});
// layer list
var myWidget = new LayerList({
map: response.map,
layers: arcgisUtils.getLayerList(response)
},"layerList");
myWidget.startup();
//get the layer from the map using the id and set it as the swipe layer.
if(id){
var swipeLayer = map.getLayer(id);
var swipeWidget = new LayerSwipe({
type: "vertical", //Try switching to "scope" or "horizontal"
map: map,
layers: [swipeLayer]
}, "swipeDiv");
swipeWidget.startup();
}
});
});
</script>
</head>
<body class="claro">
<div class="container" data-dojo-type="dijit/layout/BorderContainer"data-dojo-props="design:'headline',gutters:false">
<div id="layerListPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'right'">
<div id="layerList"></div>
</div>
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">
<div id="swipeDiv"></div>
</div>
</div>
</body>
</html>
... View more
08-05-2016
04:56 AM
|
1
|
0
|
1893
|
|
POST
|
Remove the data-dojo-props attribute for both dividers and change you CSS: #layerListPane{
width:25%;
float:right;
}
#map{
width: 75%;
float:left;
}
... View more
08-05-2016
04:15 AM
|
1
|
1
|
1893
|
|
POST
|
Lots of clicks Unfortunately there does not seem to be an easy way (that I can find) to copy unique value symbology colours between different geometry types, not with layer files or Python. What about a colour ramp with a wide range of colours?
... View more
08-05-2016
02:54 AM
|
1
|
0
|
759
|
|
POST
|
You will at least need a server-side page (PHP/ASP) to handle the database connect request. Then you just call the server-side page with an esri.request or AJAX call to retrieve the database query results. What geometries do you have in the database? You should be able to construct graphic layer geometries from it in some way.
... View more
08-05-2016
02:02 AM
|
1
|
1
|
3141
|
|
POST
|
Best option if it must be a rectangular grid. What is your opinion on using a hexagonal coverage "grid"? I like the way it smooths the distribution visually.
... View more
08-04-2016
11:38 PM
|
0
|
0
|
2629
|
|
POST
|
I don't think it is possible from the standard legend item symbology options. You could... 1) create a graphic from a screenshot or export which you can use in the legend as a patch, but you will have to manually edit the legend. 2) Use the legend patch tool: How To: Create a custom area or line legend patch shape 3) Bit unconventional, but if you need to show a series of different features, you can set up data driven pages for the features in an additional small data frame about the same size as the legend patch and dynamic text for the feature value for the legend label.
... View more
08-04-2016
03:11 AM
|
1
|
1
|
1329
|
|
POST
|
Extract from Layer—Help | ArcGIS for Desktop Depending on the symbology type, a layer's symbology can be modified. There are a limited number of supported symbology types for which properties and methods are available. It is good practice to first test the layer's symbologyTypeproperty. If a value of OTHER is returned, then the layer's symbology can't be modified. If the value returned is not OTHER, then the layer's symbology property will return one of the following symbology classes, each with their own unique set of methods and properties: GraduatedColorsSymbology, GraduatedSymbolsSymbology, RasterClassifiedSymbology, andUniqueValuesSymbology.
... View more
08-01-2016
11:05 PM
|
1
|
2
|
2650
|
|
POST
|
Please elaborate. Are you referring to the centroid of a feature or the centroid of the graphic layer extent?
... View more
08-01-2016
10:44 PM
|
0
|
0
|
637
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-22-2024 12:37 AM | |
| 1 | 10-02-2025 10:28 AM | |
| 1 | 09-17-2024 12:29 AM | |
| 1 | 03-15-2024 11:33 AM | |
| 1 | 03-13-2024 11:20 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-02-2026
12:31 AM
|