-
Notifications
You must be signed in to change notification settings - Fork 123
New sample: Apply mosiac rule to rasters #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 218 commits
8473b0c
51f7c30
6349008
b791ff8
6d1ba27
1f322ee
a240829
3d6ab90
26a21ab
e05b73e
8f58533
75dc3a5
e0e545c
8145835
a8903f0
82e7a94
2ce991f
d99fad3
c8e1c13
d45d1ae
56ed0d5
52fb4c9
42f678b
3a22cbb
c43331e
db8110b
9f2204b
a56fbdd
11285fd
894ed41
baa2198
b133f58
5abbed5
2757bb5
0709cbe
0da0c29
e1edbfe
f93980f
f3289a2
426642c
32f2a9c
b7f9b3e
1cb389b
9c53786
f75253d
52c3a6d
0a62a7d
1273c6e
1b0a836
d0776e4
6e783c5
e4458f6
664f09a
9cb7eae
93ca670
2c77dbe
dbd6a55
1771bdb
3b7f5fe
8f9cdce
8f95d99
a4b8182
68e1108
e006134
f4d7324
d144362
d3995bf
4f2f4e4
cf7d52a
904fb55
23e4ac2
d0c154e
3c7277f
2aa00c0
a49a3c3
ba83866
f84ee58
dcecafd
573ae5a
6cd0efc
ca64f2f
1e9a0e5
f876451
a82995b
1098e89
308013d
f3fb3a4
2875d99
9aac5f2
23ec025
9bf071f
02b7738
23866d2
7fbcda6
43f8fa3
f295325
7b3ca50
27ad40b
38e3edf
aa285f8
1e1c415
2288f97
d2ea64b
f00d337
dc340c2
1a56d07
2d92654
b209569
0e5fc1d
8e43124
71375c3
eae4977
0a4cca8
c1c2b6d
5cf8674
959a101
a002ce2
cd1a4cc
9ed26f4
a0f2be8
f9e744d
009b2f3
95f1ee9
f34287c
2ef5f63
6d0ef08
01a9bf8
bdb6833
8bb879c
7ecda20
afdb75a
d521670
e06c5fa
dc232c2
1ce5952
60b2aae
9d3158f
050dadb
7560e54
412037a
fd3a211
2a85c90
ce35ebf
933dacc
98cceae
e879c11
74ffdfc
d9a13ff
cddacc4
4e27813
37114d2
c8e6633
57d0aba
f18496b
14ee78b
b06ca29
a51e9f5
06ff35d
c3f9b7e
df045df
ba9bd94
fda9bd7
baafc2d
361160b
feecba3
fd19de5
86d8ae0
3fd88f8
b2c6174
0042265
4b36776
7b6de95
16b5b38
c7f1fd0
a6c7857
c03d3fa
ec04025
d8e9528
24f4b80
e29433e
45adb4a
3c50c80
be60da6
c274e9d
1547a07
0082b77
25b9c87
231d175
7f54ed6
b761eba
82512be
b96c3ce
b85ac22
a163fa5
2f139b7
1e8ea58
899bcf1
0498000
fbe529c
b1950ee
d73d2b1
fd53949
77c99cf
6167e9a
e1e36b6
fca016d
8b30100
7ef9ea9
a727c6e
8a24dc3
9535535
7e09406
0c15734
0aa1a57
7130e50
803e3a0
f234f33
3094a60
c801c07
ce4c038
134fdb3
a3d2423
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||
# Apply mosaic rule to rasters | ||||||
|
||||||
Apply mosaic rule to a mosaic dataset of rasters. | ||||||
|
||||||
 | ||||||
|
||||||
## Use case | ||||||
|
||||||
An image service can use a mosaic rule to mosaic multiple rasters on-the-fly. A mosaic rule can specify which rasters are selected, and how the selected rasters are z-ordered. It can also specify how overlapping pixels from different rasters at the same location are resolved. | ||||||
|
||||||
For example, when using the "By Attribute" mosaic method, the values in an attribute field are used to sort the images, and when using the "Center" method, the image closest to the center of the display is positioned as the top image in the mosaic. Additionally, mosaic operation allows you to define how to resolve the overlapping cells, such as choosing a blending operation. | ||||||
|
||||||
Specifying mosaic rules is useful for viewing overlapping rasters. For example, using the "By Attribute" mosaic method to sort the rasters based on their acquisition date allows the newest image to be on top. Using "mean" mosaic operation makes the overlapping areas contain the mean cell values from all the overlapping rasters. | ||||||
|
||||||
## How to use the sample | ||||||
|
||||||
When the rasters are loaded, choose from a list of preset mosaic rules to apply to the rasters. | ||||||
|
||||||
## How it works | ||||||
|
||||||
1. Create an `ImageServiceRaster` using the service's URL. | ||||||
2. Create a `MosaicRule` object and set it to the image service raster using `setMosaicRule(mosaicRule)`, if it does not specify a mosaic rule. | ||||||
3. Create a `RasterLayer` from the image service raster and add it to the map. | ||||||
4. Set the `mosaicMethod`, `mosaicOperation` and other properties of the mosaic rule object accordingly to specify the rule on the raster dataset. | ||||||
|
||||||
## Relevant API | ||||||
|
||||||
* ImageServiceRaster | ||||||
* MosaicMethod | ||||||
* MosaicOperation | ||||||
* MosaicRule | ||||||
|
||||||
## About the data | ||||||
|
||||||
This sample uses a [raster image service](https://sampleserver7.arcgisonline.com/server/rest/services/amberg_germany/ImageServer) hosted on *ArcGIS Online* that shows aerial images of Amberg, Germany. | ||||||
|
||||||
## Additional information | ||||||
|
||||||
For more information, see [Understanding the mosaicking rules](https://desktop.arcgis.com/en/arcmap/latest/manage-data/raster-and-images/understanding-the-mosaicking-rules-for-a-mosaic-dataset.htm) from *ArcGIS Desktop* documentation. To learn more about how to define certain mosaic rules, see [Mosaic rule objects](https://developers.arcgis.com/documentation/common-data-types/mosaic-rules.htm) from *ArcGIS for Developers*. | ||||||
|
||||||
## Tags | ||||||
|
||||||
image service, mosaic rule, mosaic method, raster | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the checker is picking up that these aren't sorted alphabetically, gosh I wouldn't have noticed this at all otherwise!
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"category": "Raster", | ||
"description": "Apply mosaic rule to a mosaic dataset of rasters.", | ||
"ignore": false, | ||
"images": [ | ||
"ApplyMosaicRuleToRasters.png" | ||
], | ||
"keywords": [ | ||
"image service", | ||
"mosaic method", | ||
"mosaic rule", | ||
"raster", | ||
"ImageServiceRaster", | ||
"MosaicMethod", | ||
"MosaicOperation", | ||
"MosaicRule" | ||
], | ||
"redirect_from":"", | ||
"relevant_apis": [ | ||
"ImageServiceRaster", | ||
"MosaicMethod", | ||
"MosaicOperation", | ||
"MosaicRule" | ||
], | ||
"snippets": [ | ||
"src/main/java/com/esri/samples/apply_mosaic_rule_to_rasters/ApplyMosaicRuleToRastersSample.java" | ||
], | ||
"title": "Apply mosaic rule to rasters" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
plugins { | ||
id 'application' | ||
id 'org.openjfx.javafxplugin' version '0.0.8' | ||
} | ||
|
||
group = 'com.esri.samples' | ||
|
||
ext { | ||
arcgisVersion = '100.10.0' | ||
} | ||
|
||
javafx { | ||
version = "11.0.2" | ||
modules = [ 'javafx.controls', 'javafx.fxml'] | ||
} | ||
|
||
compileJava.options.encoding = 'UTF-8' | ||
|
||
repositories { | ||
jcenter() | ||
maven { | ||
url 'https://esri.jfrog.io/artifactory/arcgis' | ||
} | ||
maven { | ||
url 'http://olympus.esri.com/artifactory/arcgisruntime-repo' | ||
} | ||
} | ||
|
||
configurations { | ||
natives | ||
} | ||
|
||
dependencies { | ||
implementation "com.esri.arcgisruntime:arcgis-java:$arcgisVersion" | ||
natives "com.esri.arcgisruntime:arcgis-java-jnilibs:$arcgisVersion" | ||
natives "com.esri.arcgisruntime:arcgis-java-resources:$arcgisVersion" | ||
} | ||
|
||
task createGradlePropertiesAndWriteApiKey { | ||
description = "Creates a new gradle.properties file with an empty API key variable in the user home ./gradle folder, if the file doesn't already exist." | ||
group = "build" | ||
def propertiesFile = new File("${System.properties.getProperty("user.home")}/.gradle/gradle.properties") | ||
if (!propertiesFile.exists()) { | ||
print("Go to " + new URL("https://developers.arcgis.com/dashboard") + " to get an API key.") | ||
print(" Add your API key to ${System.properties.getProperty("user.home")}\\.gradle\\gradle.properties.") | ||
propertiesFile.write("apiKey = ") | ||
} | ||
} | ||
|
||
task copyNatives(type: Copy) { | ||
description = "Copies the arcgis native libraries into the project build directory for development." | ||
group = "build" | ||
configurations.natives.asFileTree.each { | ||
from(zipTree(it)) | ||
} | ||
// store native libraries in a common location shared with other samples | ||
into "${System.properties.getProperty("user.home")}/.arcgis/$arcgisVersion" | ||
} | ||
|
||
run { | ||
doFirst { | ||
// sets the API key from the gradle.properties file as a Java system property | ||
systemProperty 'apiKey', apiKey | ||
Comment on lines
+62
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just noticed this doesn't run the task There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem to do that for me, I have to run the task There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should look into this more: if Jon is coming across this as a first time using this task others will too. I can take a look on a fresh windows setup! |
||
} | ||
dependsOn copyNatives | ||
mainClassName = 'com.esri.samples.apply_mosaic_rule_to_rasters.ApplyMosaicRuleToRastersLauncher' | ||
} | ||
|
||
jar { | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
manifest { | ||
attributes("Main-Class": "$mainClassName") | ||
} | ||
from { | ||
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } | ||
} | ||
} | ||
|
||
task productionZip(type: Zip) { | ||
group = 'distribution' | ||
from copyNatives | ||
from jar.destinationDirectory | ||
into (project.name) | ||
archiveBaseName = project.name | ||
} | ||
|
||
wrapper { | ||
gradleVersion = '6.5.1' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#!/usr/bin/env sh | ||
|
||
############################################################################## | ||
## | ||
## Gradle start up script for UN*X | ||
## | ||
############################################################################## | ||
|
||
# Attempt to set APP_HOME | ||
# Resolve links: $0 may be a link | ||
PRG="$0" | ||
# Need this for relative symlinks. | ||
while [ -h "$PRG" ] ; do | ||
ls=`ls -ld "$PRG"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
PRG=`dirname "$PRG"`"/$link" | ||
fi | ||
done | ||
SAVED="`pwd`" | ||
cd "`dirname \"$PRG\"`/" >/dev/null | ||
APP_HOME="`pwd -P`" | ||
cd "$SAVED" >/dev/null | ||
|
||
APP_NAME="Gradle" | ||
APP_BASE_NAME=`basename "$0"` | ||
|
||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
DEFAULT_JVM_OPTS="" | ||
|
||
# Use the maximum available, or set MAX_FD != -1 to use that value. | ||
MAX_FD="maximum" | ||
|
||
warn () { | ||
echo "$*" | ||
} | ||
|
||
die () { | ||
echo | ||
echo "$*" | ||
echo | ||
exit 1 | ||
} | ||
|
||
# OS specific support (must be 'true' or 'false'). | ||
cygwin=false | ||
msys=false | ||
darwin=false | ||
nonstop=false | ||
case "`uname`" in | ||
CYGWIN* ) | ||
cygwin=true | ||
;; | ||
Darwin* ) | ||
darwin=true | ||
;; | ||
MINGW* ) | ||
msys=true | ||
;; | ||
NONSTOP* ) | ||
nonstop=true | ||
;; | ||
esac | ||
|
||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
|
||
# Determine the Java command to use to start the JVM. | ||
if [ -n "$JAVA_HOME" ] ; then | ||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
# IBM's JDK on AIX uses strange locations for the executables | ||
JAVACMD="$JAVA_HOME/jre/sh/java" | ||
else | ||
JAVACMD="$JAVA_HOME/bin/java" | ||
fi | ||
if [ ! -x "$JAVACMD" ] ; then | ||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
Please set the JAVA_HOME variable in your environment to match the | ||
location of your Java installation." | ||
fi | ||
else | ||
JAVACMD="java" | ||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
Please set the JAVA_HOME variable in your environment to match the | ||
location of your Java installation." | ||
fi | ||
|
||
# Increase the maximum file descriptors if we can. | ||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | ||
MAX_FD_LIMIT=`ulimit -H -n` | ||
if [ $? -eq 0 ] ; then | ||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
MAX_FD="$MAX_FD_LIMIT" | ||
fi | ||
ulimit -n $MAX_FD | ||
if [ $? -ne 0 ] ; then | ||
warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
fi | ||
else | ||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
fi | ||
fi | ||
|
||
# For Darwin, add options to specify how the application appears in the dock | ||
if $darwin; then | ||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
fi | ||
|
||
# For Cygwin, switch paths to Windows format before running java | ||
if $cygwin ; then | ||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
JAVACMD=`cygpath --unix "$JAVACMD"` | ||
|
||
# We build the pattern for arguments to be converted via cygpath | ||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
SEP="" | ||
for dir in $ROOTDIRSRAW ; do | ||
ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
SEP="|" | ||
done | ||
OURCYGPATTERN="(^($ROOTDIRS))" | ||
# Add a user-defined pattern to the cygpath arguments | ||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
fi | ||
# Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
i=0 | ||
for arg in "$@" ; do | ||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
|
||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
else | ||
eval `echo args$i`="\"$arg\"" | ||
fi | ||
i=$((i+1)) | ||
done | ||
case $i in | ||
(0) set -- ;; | ||
(1) set -- "$args0" ;; | ||
(2) set -- "$args0" "$args1" ;; | ||
(3) set -- "$args0" "$args1" "$args2" ;; | ||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
esac | ||
fi | ||
|
||
# Escape application args | ||
save () { | ||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | ||
echo " " | ||
} | ||
APP_ARGS=$(save "$@") | ||
|
||
# Collect all arguments for the java command, following the shell quoting and substitution rules | ||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | ||
|
||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong | ||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then | ||
cd "$(dirname "$0")" | ||
fi | ||
|
||
exec "$JAVACMD" "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to keep
raster
as singular throughout, unless there's a mechanism to apply a rule to a whole group of rasters in bulk?However if the design for this is already finalised, just disregard this comment 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The design has been finalized, so I'll stick with rasters!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Jon here, though checking the design I now understand why it's plural: