sockg

SOC-KG

The Soil Organic Carbon Knowledge Graph (SOCKG) enhances robust soil carbon modeling, which is crucial for voluntary carbon markets.

27.1M triples
90 classes
107 properties
7.1M subjects

The Soil Organic Carbon Knowledge Graph (SOCKG) enhances robust soil carbon modeling, which is crucial for voluntary carbon markets. These markets create incentives for climate-friendly practices by encouraging the retention of carbon in soil, reducing atmospheric carbon levels. Industry sectors, like energy and transportation, purchase carbon credits to offset unavoidable emissions, while farmers and land managers are rewarded for adopting practices that increase soil organic carbon (SOC). For these markets to function effectively, it is essential to have advanced soil carbon modeling technologies that accurately measure SOC content, predict changes, and link those changes to specific agricultural practices. High-quality data is central to this process. By integrating siloed data into a cohesive knowledge graph, linking it to broader datasets, and establishing infrastructure for its sustainability, SOCKG can play a transformative role in enabling and accelerating the growth of this emerging market.

What is the average change in SOC stock (kg C ha-1 yr-1) in 0-30 cm soils? (5, 10, 15…)? This would require using equation above for Year 0 (=baseline year or first year of collection) and Year 5, 10, 15, etc…, then calculating the difference/# years. a. For each year, Delta SOC stock (kg ha-1) = Delta SOC stock (kg ha-1)yearX- Delta SOC stock (kg ha-1)baseline b. Average the Delta SOC stock (0-30cm) for the treatments of interest.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX spatial: <http://purl.org/spatialai/spatial/spatial-full#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX unit: <http://qudt.org/vocab/unit/>
PREFIX ofn: <http://www.ontotext.com/sparql/functions/>


# Sample so I dont have to add to group by
SELECT ?fieldId ?treatmentMethod (ROUND(AVG(?literalChange) * 100) / 100 AS ?AVGLiteralChange) (ROUND(AVG(?pctChange) * 10000) / 10000 AS ?AVGPctChange) ?SOCStockUnit (COUNT(*) AS ?NumOfSamples)
WHERE {
    
    #Get baseline data
    {
        SELECT ?BLFieldId ?BLTreatmentMethod ?baselineDate ?baselineSOCStock  {
            {
                SELECT DISTINCT (?fieldId AS ?BLFieldId) (?treatmentMethod AS ?BLTreatmentMethod) (MIN(?date) AS ?Date) ?baselineDate (ROUND(AVG(?SUMsocKgHa) * 100) / 100 AS ?baselineSOCStock) 
                WHERE {    
                    {
                        # Group based on field and treatment
                        SELECT ?baselineFieldId ?baselineTreatmentMethod (MIN(?date) AS ?baselineDate)  
                        WHERE {
                            # Update this and Line 100, 255
                            BIND("6"^^xsd:double AS ?maxDepth)   
                            BIND("0"^^xsd:double AS ?minDepth)   


                            ?expUnit a sockg:ExperimentalUnit ;
                                     kwg-ont:sfWithin ?spatial_data .
                            FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not
                            ?spatial_data dcterms:identifier ?baselineFieldId .




                            # Gather CHEM samples
                            ?soilChem a sockg:SoilChemicalSample ;
                                      sockg:usesTreatment ?baselineTreatment ;
                                      sockg:lowerDepth ?LDepth ;
                                      sockg:upperDepth ?UDepth ;
                                      sockg:fromUnit ?expUnit ;
                                      sockg:hasMeasurement ?meas ;
                                      dcterms:date ?date .
                            ?LDepth qudt:numericValue ?lowerDepth .
                            ?UDepth qudt:numericValue ?upperDepth .
                            ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                                  qudt:quantityValue ?result .
                            ?result qudt:numericValue ?soc .


                            FILTER (?soc != 0)
                            FILTER (
                                (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                                (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                                (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                                # Implicitly implied: user defined range within the layer
                            )


                            # ===================
                            # Gather PHYS samples
                            ?physSample a sockg:SoilPhysicalSample ;
                                        sockg:fromUnit ?expUnit ;
                                        sockg:usesTreatment ?baselineTreatment ;
                                        sockg:lowerDepth ?physLDepth ;
                                        dcterms:date ?date .
                            # To keep it simple, assume phys and chem samples have same layer depths
                            ?physLDepth qudt:numericValue ?physLowerDepth .
                            FILTER (?physLowerDepth = ?lowerDepth)




                            # Update this and Line 220, 349
                            ?treatment dcterms:identifier ?treatmentId ;
                          # Update what treatment method you want to group based off

                                   # Update what treatment method you want to group based off   
 <https://idir.uta.edu/sockg-ontology#irrigation> ?baselineTreatmentMethod .
                        }
                        GROUP BY ?baselineFieldId ?baselineTreatmentMethod
                    }




                    #Get All values 
                    {    
                        # return data and group by exp unit Id, treatment, and date
                        SELECT ?fieldId ?expUnitId ?treatment ?date ?bucket ?minDepth ?maxDepth (SUM(DISTINCT ?SOCstock) AS ?SUMsocKgHa) (MIN(?upperDepth) AS ?highestDepth) (MAX(?lowerDepth) AS ?lowestDepth) ?depthUnit
                        WHERE {     
                            # Update this and all data: Line 25, 255
                            BIND("6"^^xsd:double AS ?maxDepth)   
                            BIND("0"^^xsd:double AS ?minDepth)   


                            ?expUnit a sockg:ExperimentalUnit ;
                                     dcterms:identifier ?expUnitId ;
                                     kwg-ont:sfWithin ?spatial_data .
                            FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not site ID
                            ?spatial_data dcterms:identifier ?fieldId .        


                            # Gather CHEM samples
                            ?soilChem a sockg:SoilChemicalSample ;
                                      sockg:usesTreatment ?treatment ;
                                      sockg:lowerDepth ?LDepth ;
                                      sockg:upperDepth ?UDepth ;
                                      sockg:hasMeasurement ?meas ;
                                      sockg:fromUnit ?expUnit ;
                                      dcterms:date ?date .

                            ?LDepth qudt:numericValue ?lowerDepth .
                            ?UDepth qudt:numericValue ?upperDepth ;
                                    qudt:hasUnit ?depthUnit .
                            ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                                  qudt:quantityValue ?result .
                            ?result qudt:numericValue ?soc ;
                                    qudt:hasUnit ?socUnit .
                            FILTER (?soc != 0)
                            FILTER (
                                (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                                (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                                (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                                # Implicitly implied: user defined range within the layer
                            )


                            # ===================
                            # Gather PHYS samples
                            ?physSample a sockg:SoilPhysicalSample ;
                                        sockg:fromUnit ?expUnit ;
                                        sockg:usesTreatment ?treatment ;
                                        sockg:lowerDepth ?physLDepth ;
                                        sockg:hasMeasurement ?physMeasurement ;
                                        dcterms:date ?date .
                            # To keep it simple, assume phys and chem samples have same layer depths
                            ?physLDepth qudt:numericValue ?physLowerDepth .
                            FILTER (?physLowerDepth = ?lowerDepth)
                            ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
                                             qudt:quantityValue ?physResult .
                            ?physResult qudt:numericValue ?bulkDensity ;
                                        qudt:hasUnit ?bulkDensityUnit .


                            BIND(IF(?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth,        # Standard Case   
                                    ?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100,         
                                    IF(?upperDepth < ?minDepth && ?lowerDepth > ?minDepth,          # Layer is partially above specified area   
                                        (?soc * ?bulkDensity * (?lowerDepth - ?minDepth) * 100) ,   
                                        IF(?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth,        # Layer is partially below specified area   
                                            (?soc * ?bulkDensity * (?maxDepth - ?upperDepth) * 100) ,   
                                            (?soc * ?bulkDensity * (?maxDepth - ?minDepth) * 100)        # Specified region is contained within a layer   
                                        )   
                                    )   
                                ) AS ?SOCstock   
                            )   


                            #UPDATE: 330
                            # To group samples with similar dates
                            BIND(xsd:dateTime(CONCAT(STR(?date), "T00:00:00")) AS ?dt)
                            BIND(?dt - "2000-01-01T00:00:00"^^xsd:dateTime AS ?duration)
                            BIND(ofn:asDays(?duration) AS ?days)
                            BIND(ROUND(?days / 30) AS ?bucket) 


                        } 
                        # fieldId should NEVER anywhere but last so its grouping is insignificant 
                        GROUP BY ?expUnitId ?bucket ?treatment ?depthUnit ?minDepth ?maxDepth ?fieldId ?date ?expUnitId
                    }    


                    FILTER(?maxDepth <= ?lowestDepth && ?minDepth >= ?highestDepth)




                    # Update this and Line 84, 349
                    ?treatment dcterms:identifier ?treatmentId ;
                      # Update what treatment method you want to group based off
                               <https://idir.uta.edu/sockg-ontology#irrigation> ?treatmentMethod .




                    FILTER(?baselineFieldId = ?fieldId && ?baselineTreatmentMethod = ?treatmentMethod)




                    BIND(SUBSTR(str(?depthUnit), 28) AS ?parsedDepthUnit)
                    BIND(CONCAT(str(?minDepth), "-", str(?maxDepth), ?parsedDepthUnit) AS ?depthRange)
                    BIND(unit:KiloGM-Per-Ha AS ?SOCStockUnit)
                }    
                # fieldId should NEVER anywhere but last so its grouping is insignificant 
                GROUP BY ?fieldId ?treatmentMethod ?bucket ?depthRange ?baselineDate ?SOCStockUnit 
                ORDER BY ?treatmentMethod ?fieldId ?date
            }
            FILTER(?baselineDate = ?Date)
        }




    }




    #Get All values 
    {
        SELECT DISTINCT ?fieldId ?treatmentMethod (MIN(?date) AS ?Date) ?depthRange (ROUND(AVG(?SUMsocKgHa) * 100) / 100 AS ?AVGsocKgHa) ?SOCStockUnit
        WHERE {    
            {    
                # return data and group by exp unit Id, treatment, and date
                SELECT ?fieldId ?expUnitId ?treatment ?date ?bucket ?minDepth ?maxDepth (SUM(DISTINCT ?SOCstock) AS ?SUMsocKgHa) (MIN(?upperDepth) AS ?highestDepth) (MAX(?lowerDepth) AS ?lowestDepth) ?depthUnit
                WHERE {     
                    # Update this and Line 25, 100
                    BIND("6"^^xsd:double AS ?maxDepth)   
                    BIND("0"^^xsd:double AS ?minDepth)   


                    ?expUnit a sockg:ExperimentalUnit ;
                             dcterms:identifier ?expUnitId ;
                             kwg-ont:sfWithin ?spatial_data .
                    FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not site ID
                    ?spatial_data dcterms:identifier ?fieldId .        




                    # Gather CHEM samples
                    ?soilChem a sockg:SoilChemicalSample ;
                              sockg:usesTreatment ?treatment ;
                              sockg:lowerDepth ?LDepth ;
                              sockg:upperDepth ?UDepth ;
                              sockg:hasMeasurement ?meas ;
                              sockg:fromUnit ?expUnit ;
                              dcterms:date ?date .




                    ?LDepth qudt:numericValue ?lowerDepth .
                    ?UDepth qudt:numericValue ?upperDepth ;
                            qudt:hasUnit ?depthUnit .
                    ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                          qudt:quantityValue ?result .
                    ?result qudt:numericValue ?soc ;
                            qudt:hasUnit ?socUnit .
                    FILTER (?soc != 0)
                    FILTER (
                        (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                        (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                        (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                        # Implicitly implied: user defined range within the layer
                    )








                    # ===================
                    # Gather PHYS samples
                    ?physSample a sockg:SoilPhysicalSample ;
                                sockg:fromUnit ?expUnit ;
                                sockg:usesTreatment ?treatment ;
                                sockg:lowerDepth ?physLDepth ;
                                sockg:hasMeasurement ?physMeasurement ;
                                dcterms:date ?date .
                    # To keep it simple, assume phys and chem samples have same layer depths
                    ?physLDepth qudt:numericValue ?physLowerDepth .
                    FILTER (?physLowerDepth = ?lowerDepth)
                    ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
                                     qudt:quantityValue ?physResult .
                    ?physResult qudt:numericValue ?bulkDensity ;
                                qudt:hasUnit ?bulkDensityUnit .




                    BIND(IF(?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth,        # Standard Case   
                            ?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100,         
                            IF(?upperDepth < ?minDepth && ?lowerDepth > ?minDepth,          # Layer is partially above specified area   
                                (?soc * ?bulkDensity * (?lowerDepth - ?minDepth) * 100) ,   
                                IF(?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth,        # Layer is partially below specified area   
                                    (?soc * ?bulkDensity * (?maxDepth - ?upperDepth) * 100) ,   
                                    (?soc * ?bulkDensity * (?maxDepth - ?minDepth) * 100)        # Specified region is contained within a layer   
                                )   
                            )   
                        ) AS ?SOCstock   
                    )   


                                        #UPDATE: 194
                    # To group samples with similar dates
                    BIND(xsd:dateTime(CONCAT(STR(?date), "T00:00:00")) AS ?dt)
                    BIND(?dt - "2000-01-01T00:00:00"^^xsd:dateTime AS ?duration)
                    BIND(ofn:asDays(?duration) AS ?days)
                    BIND(ROUND(?days / 30) AS ?bucket) 


                } 
                # fieldId should NEVER anywhere but last so its grouping is insignificant 
                GROUP BY ?expUnitId ?bucket ?treatment ?depthUnit ?minDepth ?maxDepth ?fieldId ?date ?expUnitId
            }    




            FILTER(?maxDepth <= ?lowestDepth && ?minDepth >= ?highestDepth)


                        # Update this and Line 84, 220
            ?treatment dcterms:identifier ?treatmentId ;
                       # Update what treatment method you want to group based off
                       <https://idir.uta.edu/sockg-ontology#irrigation> ?treatmentMethod .




            BIND(SUBSTR(str(?depthUnit), 28) AS ?parsedDepthUnit)
            BIND(CONCAT(str(?minDepth), "-", str(?maxDepth), ?parsedDepthUnit) AS ?depthRange)
            BIND(unit:KiloGM-Per-Ha AS ?SOCStockUnit)
        }    
        # fieldId should NEVER anywhere but last so its grouping is insignificant 
        GROUP BY ?treatmentMethod ?bucket ?depthRange ?baselineDate ?SOCStockUnit ?fieldId 
        ORDER BY ?treatmentMethod ?fieldId ?date
    }
    FILTER(?BLFieldId = ?fieldId && ?BLTreatmentMethod = ?treatmentMethod && ?baselineDate != ?Date)
    
    BIND((?AVGsocKgHa - ?baselineSOCStock) / ?baselineSOCStock AS ?pctChange)
    BIND((?AVGsocKgHa - ?baselineSOCStock) AS ?literalChange)




}
GROUP BY ?fieldId ?treatmentMethod ?SOCStockUnit
ORDER BY DESC(?AVGPctChange)
graph TD
What is the average SOC stock (kg C ha-1) for 0-30 cm? a. For each field replicate sampled during the experiment (date) calculate SOC stock. * SOC stock (kg ha-1)= Organic C (g C/kg soil) * Bulk Density(g/cm3) * Soil depth(cm) * 100. 1ha=10,000m2 b. For each field replicate, sum kg ha-1 for all depth layers (0-5cm, 5-10cm, 10-30cm). If multiple soil increments measured between 0-30 cm, equation is the summation of calculation above for each increment. c. Average the SOC stock (0-30cm) for the treatments of interest.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX spatial: <http://purl.org/spatialai/spatial/spatial-full#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX unit: <http://qudt.org/vocab/unit/>
PREFIX ofn: <http://www.ontotext.com/sparql/functions/>


SELECT DISTINCT ?fieldId ?treatmentMethod (MIN(?date) AS ?Date) ?depthRange (ROUND(AVG(?SUMsocKgHa) * 100) / 100 AS ?AVGsocKgHa) ?SOCStockUnit
WHERE {    
    {    


        SELECT ?fieldId ?treatmentMethod ?date ?bucket ?minDepth ?maxDepth (SUM(DISTINCT ?SOCstock) AS ?SUMsocKgHa) (MIN(?upperDepth) AS ?highestDepth) (MAX(?lowerDepth) AS ?lowestDepth) ?depthUnit
        WHERE {     
            BIND("15"^^xsd:double AS ?maxDepth)   
            BIND("0"^^xsd:double AS ?minDepth)   


            ?expUnit a sockg:ExperimentalUnit ;
                     dcterms:identifier ?expUnitId ;
                     kwg-ont:sfWithin ?spatial_data .
            FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not site ID
            ?spatial_data dcterms:identifier ?fieldId .        


            # Gather CHEM samples
            ?soilChem a sockg:SoilChemicalSample ;
                      sockg:usesTreatment ?treatment ;
                      sockg:lowerDepth ?LDepth ;
                      sockg:upperDepth ?UDepth ;
                      sockg:hasMeasurement ?meas ;
                      sockg:fromUnit ?expUnit ;
                      dcterms:date ?date .
            ?treatment dcterms:identifier ?treatmentId ;
# Update what treatment method you want to group based off
                    <https://idir.uta.edu/sockg-ontology#irrigation> ?treatmentMethod .
            ?LDepth qudt:numericValue ?lowerDepth .
            ?UDepth qudt:numericValue ?upperDepth ;
                    qudt:hasUnit ?depthUnit .
            ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                  qudt:quantityValue ?result .
            ?result qudt:numericValue ?soc ;
                    qudt:hasUnit ?socUnit .
            FILTER (?soc != 0)
            FILTER (
                (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                # Implicitly implied: user defined range within the layer
            )


            # ===================
            # Gather PHYS samples
            ?physSample a sockg:SoilPhysicalSample ;
                        sockg:fromUnit ?expUnit ;
                        sockg:usesTreatment ?treatment ;
                        sockg:lowerDepth ?physLDepth ;
                        sockg:hasMeasurement ?physMeasurement ;
                        dcterms:date ?date .
            # To keep it simple, assume phys and chem samples have same layer depths
            ?physLDepth qudt:numericValue ?physLowerDepth .
            FILTER (?physLowerDepth = ?lowerDepth)
            ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
                             qudt:quantityValue ?physResult .
            ?physResult qudt:numericValue ?bulkDensity ;
                        qudt:hasUnit ?bulkDensityUnit .


            BIND(IF(?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth,        # Standard Case   
                    ?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100,         
                    IF(?upperDepth < ?minDepth && ?lowerDepth > ?minDepth,          # Layer is partially above specified area   
                        (?soc * ?bulkDensity * (?lowerDepth - ?minDepth) * 100) ,   
                        IF(?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth,        # Layer is partially below specified area   
                            (?soc * ?bulkDensity * (?maxDepth - ?upperDepth) * 100) ,   
                            (?soc * ?bulkDensity * (?maxDepth - ?minDepth) * 100)        # Specified region is contained within a layer   
                        )   
                    )   
                ) AS ?SOCstock   
            )   
                        
            # To group samples with similar dates
            BIND(xsd:dateTime(CONCAT(STR(?date), "T00:00:00")) AS ?dt)
            BIND(?dt - "2000-01-01T00:00:00"^^xsd:dateTime AS ?duration)
            BIND(ofn:asDays(?duration) AS ?days)
            BIND(FLOOR(?days / 30) AS ?bucket)


        } 
        # fieldId should NEVER anywhere but last so its grouping is insignificant 
        GROUP BY ?expUnitId ?bucket ?treatmentMethod ?depthUnit ?minDepth ?maxDepth ?fieldId ?date
    }    
    FILTER(?maxDepth <= ?lowestDepth && ?minDepth >= ?highestDepth)
    BIND(SUBSTR(str(?depthUnit), 28) AS ?parsedDepthUnit)
    BIND(CONCAT(str(?minDepth), "-", str(?maxDepth), ?parsedDepthUnit) AS ?depthRange)
    BIND(unit:KiloGM-Per-Ha AS ?SOCStockUnit)
}    
# fieldId should NEVER anywhere but last so its grouping is insignificant 
GROUP BY ?treatmentMethod ?bucket ?depthRange ?fieldId ?SOCStockUnit 
ORDER BY ?treatmentMethod ?fieldId ?date
graph TD
What is the average SOC Stock of available states
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT ?state (ROUND(AVG(?SOCStockExpUnit) * 100) / 100 AS ?AvgSocStock)
WHERE {
    {
        SELECT DISTINCT ?e ?date (SUM(?SOCStock) AS ?SOCStockExpUnit)
        WHERE {
            ?sc a sockg:SoilChemicalSample ;
                sockg:lowerDepth ?ld ;
                sockg:upperDepth ?ud ;
                sockg:hasMeasurement ?scm ;
                sockg:fromUnit ?e ;
                dcterms:date ?date .

            ?ld qudt:numericValue ?lowerDepth .
            ?ud qudt:numericValue ?upperDepth .

            ?scm sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
	            qudt:quantityValue ?scv .
            ?scv qudt:numericValue ?soc .

            FILTER (?soc != 0)

            ?sp a sockg:SoilPhysicalSample ;
                sockg:lowerDepth ?ldp ;
                sockg:fromUnit ?e ;
                sockg:hasMeasurement ?spm ;
                dcterms:date ?date .

            ?ldp qudt:numericValue ?physLowerDepth .

            FILTER(?lowerDepth = ?physLowerDepth)

            ?spm sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
            	qudt:quantityValue ?spv .
            ?spv qudt:numericValue ?bulkDensity ;

            BIND(?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100 AS ?SOCStock)
        }
        GROUP BY ?e ?date 
    }

    ?e a sockg:ExperimentalUnit ;
		kwg-ont:sfWithin ?w . # site
    
    ?w kwg-ont:sfWithin ?f . # field
    ?f kwg-ont:sfWithin ?s . #state
    
	?s rdfs:label ?state .
    
    FILTER (?state != "United States")
}
GROUP BY ?state
graph TD
What is the average increase in temperature from the first sample of an experimental unit for ghg flux samples.
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT DISTINCT ?expUnit ?treatment ?crop ?ChambPlacement ?label (ROUND(AVG(?DiffTemp) * 1000) / 1000 AS ?AvgTempDiff) 
				(SAMPLE(?Unit) AS ?unit) (COUNT(*) AS ?NumOfSamples) 
WHERE {
    BIND("air_temp_degc" AS ?label)

	?b a sockg:GHGFlux ;
    	sockg:hasMeasurement ?m ;
	    sockg:fromUnit ?e ;
		sockg:usesTreatment ?t ;
    	sockg:hasChamberPlacement ?cp ;
		sockg:hasCrop ?c ;
    	dcterms:date ?date .
    
    ?e dcterms:identifier ?expUnit .
    ?cp rdfs:label ?ChambPlacement .
    ?c rdfs:label ?crop .
    ?t dcterms:identifier ?treatment .

    
    ?m sockg:of ?param ;
        qudt:quantityValue ?v .
    ?param a sockg:Parameter ;
            rdfs:label ?label .
    ?v qudt:numericValue ?Value ;
        qudt:hasUnit ?Unit .
    
    {
        SELECT ?expUnit (MIN(?date) AS ?baselineDate) (SAMPLE(?baseValue) AS ?baselineValue)
        WHERE {
            ?b a sockg:GHGFlux ;
                sockg:hasMeasurement ?m ;
                sockg:fromUnit ?e ;
                dcterms:date ?date .
            
            ?e dcterms:identifier ?expUnit .
            
            ?m sockg:of ?param ;
                qudt:quantityValue ?v .
            ?param a sockg:Parameter ;
                    rdfs:label ?label .
            ?v qudt:numericValue ?baseValue ;
                qudt:hasUnit ?Unit .
        }
        GROUP BY ?expUnit
    }
    
    FILTER(?date != ?baselineDate)
    
    BIND(?Value - ?baselineValue AS ?DiffTemp)
}
GROUP BY ?expUnit ?treatment ?crop ?ChambPlacement ?label
ORDER BY DESC(?AvgTempDiff)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v22("?AvgTempDiff")
  v12("?ChambPlacement"):::projected 
  v21("?DiffTemp")
  v23("?NumOfSamples")
  v18("?Unit"):::projected 
  v17("?Value")
  v5("?b")
  v19("?baseValue")
  v20("?baselineDate")
  v20("?baselineValue")
  v10("?c")
  v9("?cp")
  v13("?crop"):::projected 
  v2("?date")
  v7("?e")
  v11("?expUnit"):::projected 
  v4("?label"):::projected 
  v6("?m")
  v15("?param")
  v8("?t")
  v14("?treatment"):::projected 
  v22("?unit")
  v16("?v")
  c13([sockg:Parameter]):::iri 
  c2([sockg:GHGFlux]):::iri 
  f0[["?date != ?baselineDate"]]
  f0 --> v2
  f0 --> v20
  bind1[/"'air_temp_degc'"/]
  bind1 --as--o v4
  v5 --"a"-->  c2
  v5 --"sockg:hasMeasurement"-->  v6
  v5 --"sockg:fromUnit"-->  v7
  v5 --"sockg:usesTreatment"-->  v8
  v5 --"sockg:hasChamberPlacement"-->  v9
  v5 --"sockg:hasCrop"-->  v10
  v5 --"dct:date"-->  v2
  v7 --"dct:identifier"-->  v11
  v9 --"rdfs:label"-->  v12
  v10 --"rdfs:label"-->  v13
  v8 --"dct:identifier"-->  v14
  v6 --"sockg:of"-->  v15
  v6 --"qudt:quantityValue"-->  v16
  v15 --"a"-->  c13
  v15 --"rdfs:label"-->  v4
  v16 --"qudt:numericValue"-->  v17
  v16 --"qudt:hasUnit"-->  v18
  v5 --"a"-->  c2
  v5 --"sockg:hasMeasurement"-->  v6
  v5 --"sockg:fromUnit"-->  v7
  v5 --"dct:date"-->  v2
  v7 --"dct:identifier"-->  v11
  v6 --"sockg:of"-->  v15
  v6 --"qudt:quantityValue"-->  v16
  v15 --"a"-->  c13
  v15 --"rdfs:label"-->  v4
  v16 --"qudt:numericValue"-->  v19
  v16 --"qudt:hasUnit"-->  v18
  bind4[/"min(?date)"/]
  v2 --o bind4
  bind4 --as--o v20
  bind5[/"sample(?baseValue)"/]
  v19 --o bind5
  bind5 --as--o v20
  bind6[/"?Value - ?baselineValue"/]
  v17 --o bind6
  v20 --o bind6
  bind6 --as--o v21
  bind10[/"numeric-round( * '1000^^xsd:integer') / '1000^^xsd:integer'"/]
  null --o bind10
  bind10 --as--o v22
  bind11[/"sample(?Unit)"/]
  v18 --o bind11
  bind11 --as--o v22
  bind12[/"count(*)"/]
  bind12 --as--o v23
Get all non-NAN values from the class BiomassCarbohydrate and their associated metadata (ExpUnit, date, crop, etc.)
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT DISTINCT ?expUnit ?date (SAMPLE(?crop) AS ?Crop) ?plantFraction (SAMPLE(?growthStage) AS ?GrowthStage) ?label (SAMPLE(?value) AS ?Value) (SAMPLE(?unit) AS ?Unit) WHERE {
    ?f a sockg:BiomassCarbohydrate ;
    	sockg:fromUnit ?e ;
    	sockg:hasPlantFraction ?pf ;
    	sockg:hasGrowthStage ?gs ;
    	sockg:hasCrop ?c ;
    	dcterms:date ?date ;
    	sockg:hasMeasurement ?m .
    
    # Get literals
    ?e dcterms:identifier ?expUnit .
    ?pf rdfs:label ?plantFraction .
    ?gs rdfs:label ?growthStage .
    ?c rdfs:label ?crop .
    
    ?m sockg:of ?param ;
    	qudt:quantityValue ?v .
    
    ?param a sockg:Parameter ;
    	rdfs:label ?label .
    
    ?v qudt:numericValue ?value ;
    	qudt:hasUnit ?unit .
}
GROUP BY ?expUnit ?date ?plantFraction ?label 
ORDER BY ?expUnit ?date ?plantFraction
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v17("?Crop")
  v18("?GrowthStage")
  v20("?Unit")
  v19("?Value")
  v8("?c")
  v11("?crop"):::projected 
  v2("?date"):::projected 
  v5("?e")
  v1("?expUnit"):::projected 
  v4("?f")
  v10("?growthStage"):::projected 
  v7("?gs")
  v14("?label"):::projected 
  v9("?m")
  v12("?param")
  v6("?pf")
  v3("?plantFraction"):::projected 
  v16("?unit"):::projected 
  v13("?v")
  v15("?value"):::projected 
  c13([sockg:Parameter]):::iri 
  c2([sockg:BiomassCarbohydrate]):::iri 
  v4 --"a"-->  c2
  v4 --"sockg:fromUnit"-->  v5
  v4 --"sockg:hasPlantFraction"-->  v6
  v4 --"sockg:hasGrowthStage"-->  v7
  v4 --"sockg:hasCrop"-->  v8
  v4 --"dct:date"-->  v2
  v4 --"sockg:hasMeasurement"-->  v9
  v5 --"dct:identifier"-->  v1
  v6 --"rdfs:label"-->  v3
  v7 --"rdfs:label"-->  v10
  v8 --"rdfs:label"-->  v11
  v9 --"sockg:of"-->  v12
  v9 --"qudt:quantityValue"-->  v13
  v12 --"a"-->  c13
  v12 --"rdfs:label"-->  v14
  v13 --"qudt:numericValue"-->  v15
  v13 --"qudt:hasUnit"-->  v16
  bind4[/"sample(?crop)"/]
  v11 --o bind4
  bind4 --as--o v17
  bind5[/"sample(?growthStage)"/]
  v10 --o bind5
  bind5 --as--o v18
  bind6[/"sample(?value)"/]
  v15 --o bind6
  bind6 --as--o v19
  bind7[/"sample(?unit)"/]
  v16 --o bind7
  bind7 --as--o v20
Where is each field in the United States located (country, state)
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX dc: <https://datacommons.org/browser/geoId>

SELECT DISTINCT ?country ?state (GROUP_CONCAT(DISTINCT ?fieldId; SEPARATOR=", ") AS ?fieldIDs) WHERE {
    ?ar a kwg-ont:AdministrativeRegion_0 ;
		rdfs:label ?country ;
    	kwg-ont:sfContains ?contained_regions .
    
    ?contained_regions a kwg-ont:AdministrativeRegion_1 .
    BIND(?contained_regions AS ?sp)
    FILTER(STRSTARTS(STR(?sp), STR(dc:)))
   
    ?sp kwg-ont:sfContains ?field ;
    	rdfs:label ?state .
    
    ?field a sockg:Location ;
    	dcterms:identifier ?fieldId .
}
GROUP BY ?country ?state
graph TD
Which fields and their associated sites are located in Texas, and in which city are these fields found? Return the Field ID, Site ID, and Location with the struct (city, state abbreviation).
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT DISTINCT ?fieldId ?site ?stateAbbr 
WHERE {
    ?s a sockg:Site ;
        kwg-ont:sfWithin ?l ;
        dcterms:identifier ?site .
    
    FILTER(STRSTARTS(STR(?l), STR(ind:Location)))
    
    ?l kwg-ont:sfWithin ?stateIRI ;
        dcterms:identifier ?fieldId .
    
    ?stateIRI rdfs:label ?stateAbbr .
    
    FILTER(?stateAbbr = "TX")

}
graph TD
Get all sites and what field they are contained in along with their postal codes.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX schema: <https://schema.org/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT DISTINCT ?site ?fieldId  (xsd:integer(?tmp) AS ?PostalCode)  WHERE {
    ?f a sockg:Site ;
    	dcterms:identifier ?site ;
    	schema:postalCode ?postalCode ;
    	kwg-ont:sfWithin ?within .
    
    ?within a sockg:Location ;
    	dcterms:identifier ?fieldId .
    
    # cant directly convert to int
    BIND(xsd:float(?postalCode) AS ?tmp)
    
}
graph TD
Which management treatment (N rate, crop rotation, tillage, residue management) results in the greatest increase of SOC stocks (0-30cm, or o-100cm) after 15 years in rainfed sites? In irrigated treatments? This asks to rank the delta SOC stock calculations above.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX spatial: <http://purl.org/spatialai/spatial/spatial-full#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX unit: <http://qudt.org/vocab/unit/>
PREFIX ofn: <http://www.ontotext.com/sparql/functions/>

SELECT ?treatmentMethod (SAMPLE(?depthRange) AS ?DepthRange) (AVG(?AVGLiteralChange) AS ?AllAvgLiteralChange) (AVG(?AVGPctChange) AS ?AllAvgPctChange) (SAMPLE(?SOCStockUnit) AS ?SOCSUnit)
WHERE {
    {
        SELECT ?fieldId ?treatmentMethod ?depthRange (ROUND(AVG(?literalChange) * 100) / 100 AS ?AVGLiteralChange) (ROUND(AVG(?pctChange) * 10000) / 10000 AS ?AVGPctChange) ?SOCStockUnit (COUNT(*) AS ?NumOfSamples)
        WHERE {
            #Get baseline data
            {
                SELECT ?BLFieldId ?BLTreatmentMethod ?baselineDate ?baselineSOCStock  {
                    {
                        SELECT DISTINCT (?fieldId AS ?BLFieldId) (?treatmentMethod AS ?BLTreatmentMethod) (MIN(?date) AS ?Date) ?baselineDate (ROUND(AVG(?SUMsocKgHa) * 100) / 100 AS ?baselineSOCStock) 
                        WHERE {    
                            {
                                # Group based on field and treatment
                                SELECT ?baselineFieldId ?baselineTreatmentMethod (MIN(?date) AS ?baselineDate)  
                                WHERE {
                                    # Update this and Line 100, 255
                                    BIND("6"^^xsd:double AS ?maxDepth)   
                                    BIND("0"^^xsd:double AS ?minDepth)   


                                    ?expUnit a sockg:ExperimentalUnit ;
                                             kwg-ont:sfWithin ?spatial_data .
                                    FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not
                                    ?spatial_data dcterms:identifier ?baselineFieldId .






                                    # Gather CHEM samples
                                    ?soilChem a sockg:SoilChemicalSample ;
                                              sockg:usesTreatment ?baselineTreatment ;
                                              sockg:lowerDepth ?LDepth ;
                                              sockg:upperDepth ?UDepth ;
                                              sockg:fromUnit ?expUnit ;
                                              sockg:hasMeasurement ?meas ;
                                              dcterms:date ?date .
                                    ?LDepth qudt:numericValue ?lowerDepth .
                                    ?UDepth qudt:numericValue ?upperDepth .
                                    ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                                          qudt:quantityValue ?result .
                                    ?result qudt:numericValue ?soc .








                                    FILTER (?soc != 0)
                                    FILTER (
                                        (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                                        (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                                        (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                                        # Implicitly implied: user defined range within the layer
                                    )








                                    # ===================
                                    # Gather PHYS samples
                                    ?physSample a sockg:SoilPhysicalSample ;
                                                sockg:fromUnit ?expUnit ;
                                                sockg:usesTreatment ?baselineTreatment ;
                                                sockg:lowerDepth ?physLDepth ;
                                                dcterms:date ?date .
                                    # To keep it simple, assume phys and chem samples have same layer depths
                                    ?physLDepth qudt:numericValue ?physLowerDepth .
                                    FILTER (?physLowerDepth = ?lowerDepth)




                                    # Update this and Line 220, 349
                                    ?treatment dcterms:identifier ?treatmentId ;
                                # Update what treatment method you want to group based off
                                               <https://idir.uta.edu/sockg-ontology#irrigation> ?baselineTreatmentMethod .
                                }
                                GROUP BY ?baselineFieldId ?baselineTreatmentMethod
                            }








                            #Get All values 
                            {    
                                # return data and group by exp unit Id, treatment, and date
                                SELECT ?fieldId ?expUnitId ?treatment ?date ?bucket ?minDepth ?maxDepth (SUM(DISTINCT ?SOCstock) AS ?SUMsocKgHa) (MIN(?upperDepth) AS ?highestDepth) (MAX(?lowerDepth) AS ?lowestDepth) ?depthUnit
                                WHERE {     
                                    # Update this and all data: Line 25, 255
                                    BIND("6"^^xsd:double AS ?maxDepth)   
                                    BIND("0"^^xsd:double AS ?minDepth)   


                                    ?expUnit a sockg:ExperimentalUnit ;
                                             dcterms:identifier ?expUnitId ;
                                             kwg-ont:sfWithin ?spatial_data .
                                    FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not site ID
                                    ?spatial_data dcterms:identifier ?fieldId .        






                                    # Gather CHEM samples
                                    ?soilChem a sockg:SoilChemicalSample ;
                                              sockg:usesTreatment ?treatment ;
                                              sockg:lowerDepth ?LDepth ;
                                              sockg:upperDepth ?UDepth ;
                                              sockg:hasMeasurement ?meas ;
                                              sockg:fromUnit ?expUnit ;
                                              dcterms:date ?date .






                                    ?LDepth qudt:numericValue ?lowerDepth .
                                    ?UDepth qudt:numericValue ?upperDepth ;
                                            qudt:hasUnit ?depthUnit .
                                    ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                                          qudt:quantityValue ?result .
                                    ?result qudt:numericValue ?soc ;
                                            qudt:hasUnit ?socUnit .
                                    FILTER (?soc != 0)
                                    FILTER (
                                        (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                                        (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                                        (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                                        # Implicitly implied: user defined range within the layer
                                    )






                                    # ===================
                                    # Gather PHYS samples
                                    ?physSample a sockg:SoilPhysicalSample ;
                                                sockg:fromUnit ?expUnit ;
                                                sockg:usesTreatment ?treatment ;
                                                sockg:lowerDepth ?physLDepth ;
                                                sockg:hasMeasurement ?physMeasurement ;
                                                dcterms:date ?date .
                                    # To keep it simple, assume phys and chem samples have same layer depths
                                    ?physLDepth qudt:numericValue ?physLowerDepth .
                                    FILTER (?physLowerDepth = ?lowerDepth)
                                    ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
                                                     qudt:quantityValue ?physResult .
                                    ?physResult qudt:numericValue ?bulkDensity ;
                                                qudt:hasUnit ?bulkDensityUnit .


                                    
                                    BIND(IF(?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth,        # Standard Case   
                                            ?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100,         
                                            IF(?upperDepth < ?minDepth && ?lowerDepth > ?minDepth,          # Layer is partially above specified area   
                                                (?soc * ?bulkDensity * (?lowerDepth - ?minDepth) * 100) ,   
                                                IF(?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth,        # Layer is partially below specified area   
                                                    (?soc * ?bulkDensity * (?maxDepth - ?upperDepth) * 100) ,   
                                                    (?soc * ?bulkDensity * (?maxDepth - ?minDepth) * 100)        # Specified region is contained within a layer   
                                                )   
                                            )   
                                        ) AS ?SOCstock   
                                    )   






                                    #UPDATE: 330
                                    # To group samples with similar dates
                                    BIND(xsd:dateTime(CONCAT(STR(?date), "T00:00:00")) AS ?dt)
                                    BIND(?dt - "2000-01-01T00:00:00"^^xsd:dateTime AS ?duration)
                                    BIND(ofn:asDays(?duration) AS ?days)
                                    BIND(ROUND(?days / 30) AS ?bucket) 




                                } 
                                # fieldId should NEVER anywhere but last so its grouping is insignificant 
                                GROUP BY ?expUnitId ?bucket ?treatment ?depthUnit ?minDepth ?maxDepth ?fieldId ?date ?expUnitId
                            }    




                            FILTER(?maxDepth <= ?lowestDepth && ?minDepth >= ?highestDepth)


                            # Update this and Line 84, 349
                            ?treatment dcterms:identifier ?treatmentId ;
                        # Update what treatment method you want to group based off
                                       <https://idir.uta.edu/sockg-ontology#irrigation> ?treatmentMethod .




                            FILTER(?baselineFieldId = ?fieldId && ?baselineTreatmentMethod = ?treatmentMethod)




                            BIND(SUBSTR(str(?depthUnit), 28) AS ?parsedDepthUnit)
                            BIND(CONCAT(str(?minDepth), "-", str(?maxDepth), ?parsedDepthUnit) AS ?depthRange)
                            BIND(unit:KiloGM-Per-Ha AS ?SOCStockUnit)
                        }    
                        # fieldId should NEVER anywhere but last so its grouping is insignificant 
                        GROUP BY ?fieldId ?treatmentMethod ?bucket ?depthRange ?baselineDate ?SOCStockUnit 
                        ORDER BY ?treatmentMethod ?fieldId ?date
                    }
                    FILTER(?baselineDate = ?Date)
                }


            }




            #Get All values 
            {
                SELECT DISTINCT ?fieldId ?treatmentMethod (MIN(?date) AS ?Date) ?depthRange (ROUND(AVG(?SUMsocKgHa) * 100) / 100 AS ?AVGsocKgHa) ?SOCStockUnit
                WHERE {    
                    {    
                        # return data and group by exp unit Id, treatment, and date
                        SELECT ?fieldId ?expUnitId ?treatment ?date ?bucket ?minDepth ?maxDepth (SUM(DISTINCT ?SOCstock) AS ?SUMsocKgHa) (MIN(?upperDepth) AS ?highestDepth) (MAX(?lowerDepth) AS ?lowestDepth) ?depthUnit
                        WHERE {     
                            # Update this and Line 25, 100
                            BIND("6"^^xsd:double AS ?maxDepth)   
                            BIND("0"^^xsd:double AS ?minDepth)   








                            ?expUnit a sockg:ExperimentalUnit ;
                                     dcterms:identifier ?expUnitId ;
                                     kwg-ont:sfWithin ?spatial_data .
                            FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) # Make sure it is a field, not site ID
                            ?spatial_data dcterms:identifier ?fieldId .        




                            # Gather CHEM samples
                            ?soilChem a sockg:SoilChemicalSample ;
                                      sockg:usesTreatment ?treatment ;
                                      sockg:lowerDepth ?LDepth ;
                                      sockg:upperDepth ?UDepth ;
                                      sockg:hasMeasurement ?meas ;
                                      sockg:fromUnit ?expUnit ;
                                      dcterms:date ?date .




                            ?LDepth qudt:numericValue ?lowerDepth .
                            ?UDepth qudt:numericValue ?upperDepth ;
                                    qudt:hasUnit ?depthUnit .
                            ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
                                  qudt:quantityValue ?result .
                            ?result qudt:numericValue ?soc ;
                                    qudt:hasUnit ?socUnit .
                            FILTER (?soc != 0)
                            FILTER (
                                (?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth) || # Entire layer is within the defined range
                                (?upperDepth < ?minDepth && ?lowerDepth > ?minDepth) || # Partially above the range
                                (?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth) # Partially below the range
                                # Implicitly implied: user defined range within the layer
                            )










                            # ===================
                            # Gather PHYS samples
                            ?physSample a sockg:SoilPhysicalSample ;
                                        sockg:fromUnit ?expUnit ;
                                        sockg:usesTreatment ?treatment ;
                                        sockg:lowerDepth ?physLDepth ;
                                        sockg:hasMeasurement ?physMeasurement ;
                                        dcterms:date ?date .
                            # To keep it simple, assume phys and chem samples have same layer depths
                            ?physLDepth qudt:numericValue ?physLowerDepth .
                            FILTER (?physLowerDepth = ?lowerDepth)
                            ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
                                             qudt:quantityValue ?physResult .
                            ?physResult qudt:numericValue ?bulkDensity ;
                                        qudt:hasUnit ?bulkDensityUnit .




                            BIND(IF(?upperDepth >= ?minDepth && ?lowerDepth <= ?maxDepth,        # Standard Case   
                                    ?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100,         
                                    IF(?upperDepth < ?minDepth && ?lowerDepth > ?minDepth,          # Layer is partially above specified area   
                                        (?soc * ?bulkDensity * (?lowerDepth - ?minDepth) * 100) ,   
                                        IF(?upperDepth < ?maxDepth && ?lowerDepth > ?maxDepth,        # Layer is partially below specified area   
                                            (?soc * ?bulkDensity * (?maxDepth - ?upperDepth) * 100) ,   
                                            (?soc * ?bulkDensity * (?maxDepth - ?minDepth) * 100)        # Specified region is contained within a layer   
                                        )   
                                    )   
                                ) AS ?SOCstock   
                            )   


                            #UPDATE: 194
                            # To group samples with similar dates
                            BIND(xsd:dateTime(CONCAT(STR(?date), "T00:00:00")) AS ?dt)
                            BIND(?dt - "2000-01-01T00:00:00"^^xsd:dateTime AS ?duration)
                            BIND(ofn:asDays(?duration) AS ?days)
                            BIND(ROUND(?days / 30) AS ?bucket) 


                        } 
                        # fieldId should NEVER anywhere but last so its grouping is insignificant 
                        GROUP BY ?expUnitId ?bucket ?treatment ?depthUnit ?minDepth ?maxDepth ?fieldId ?date ?expUnitId
                    }    




                    FILTER(?maxDepth <= ?lowestDepth && ?minDepth >= ?highestDepth)


                    # Update this and Line 84, 220
                    ?treatment dcterms:identifier ?treatmentId ;
                               # Update what treatment method you want to group based off
                               <https://idir.uta.edu/sockg-ontology#irrigation> ?treatmentMethod .




                    BIND(SUBSTR(str(?depthUnit), 28) AS ?parsedDepthUnit)
                    BIND(CONCAT(str(?minDepth), "-", str(?maxDepth), ?parsedDepthUnit) AS ?depthRange)
                    BIND(unit:KiloGM-Per-Ha AS ?SOCStockUnit)
                }    
                # fieldId should NEVER anywhere but last so its grouping is insignificant 
                GROUP BY ?treatmentMethod ?bucket ?depthRange ?baselineDate ?SOCStockUnit ?fieldId 
                ORDER BY ?treatmentMethod ?fieldId ?date
            }
            FILTER(?BLFieldId = ?fieldId && ?BLTreatmentMethod = ?treatmentMethod && ?baselineDate != ?Date)


            BIND((?AVGsocKgHa - ?baselineSOCStock) / ?baselineSOCStock AS ?pctChange)
            BIND((?AVGsocKgHa - ?baselineSOCStock) AS ?literalChange)








        }
        GROUP BY ?fieldId ?treatmentMethod ?SOCStockUnit ?depthRange
        ORDER BY DESC(?AVGPctChange)
    }
}
GROUP BY ?treatmentMethod
graph TD
Get all Harvest Fraction Samples and their corresponding attributes (date, expUnit, treatmentId, crop, growth stage, etc.)
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT DISTINCT ?expUnit ?treatment ?date ?crop ?plantFraction ?growthStage ?label ?Value ?Unit WHERE {
    ?b a sockg:HarvestFraction ;
    	sockg:hasMeasurement ?m ;
	    sockg:fromUnit ?e ;
    	sockg:hasPlantFraction ?pf ;
    	sockg:hasGrowthStage ?gs ;
    	sockg:hasCrop ?c ;
		sockg:usesTreatment ?t ;
    	dcterms:date ?date .
    
    ?e dcterms:identifier ?expUnit .
    ?pf rdfs:label ?plantFraction .
    ?gs rdfs:label ?growthStage .
    ?c rdfs:label ?crop .
    ?t dcterms:identifier ?treatment .

    
    ?m sockg:of ?param ;
        qudt:quantityValue ?v .
    ?param a sockg:Parameter ;
            rdfs:label ?label .
    ?v qudt:numericValue ?Value ;
        qudt:hasUnit ?Unit .
}
ORDER BY ?expUnit ?date ?label
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v18("?Unit"):::projected 
  v17("?Value"):::projected 
  v4("?b")
  v9("?c")
  v13("?crop"):::projected 
  v2("?date"):::projected 
  v6("?e")
  v1("?expUnit"):::projected 
  v12("?growthStage"):::projected 
  v8("?gs")
  v3("?label"):::projected 
  v5("?m")
  v15("?param")
  v7("?pf")
  v11("?plantFraction"):::projected 
  v10("?t")
  v14("?treatment"):::projected 
  v16("?v")
  c14([sockg:Parameter]):::iri 
  c2([sockg:HarvestFraction]):::iri 
  v4 --"a"-->  c2
  v4 --"sockg:hasMeasurement"-->  v5
  v4 --"sockg:fromUnit"-->  v6
  v4 --"sockg:hasPlantFraction"-->  v7
  v4 --"sockg:hasGrowthStage"-->  v8
  v4 --"sockg:hasCrop"-->  v9
  v4 --"sockg:usesTreatment"-->  v10
  v4 --"dct:date"-->  v2
  v6 --"dct:identifier"-->  v1
  v7 --"rdfs:label"-->  v11
  v8 --"rdfs:label"-->  v12
  v9 --"rdfs:label"-->  v13
  v10 --"dct:identifier"-->  v14
  v5 --"sockg:of"-->  v15
  v5 --"qudt:quantityValue"-->  v16
  v15 --"a"-->  c14
  v15 --"rdfs:label"-->  v3
  v16 --"qudt:numericValue"-->  v17
  v16 --"qudt:hasUnit"-->  v18
Get 10 locations from the knowledge graph, their assoicated super locations, sub locations, and s2 cells
PREFIX kwgr: <http://stko-kwg.geog.ucsb.edu/lod/resource/>
PREFIX spatial: <http://purl.org/spatialai/spatial/spatial-full#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>  
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>

SELECT DISTINCT ?loc (GROUP_CONCAT(DISTINCT ?superLoc; SEPARATOR=", ") AS ?superLocs) (GROUP_CONCAT(DISTINCT ?subLoc) AS ?subLocs) (GROUP_CONCAT(DISTINCT ?s2) AS ?s2cells) WHERE {
    ?f a sockg:Location ;
    	dcterms:identifier ?loc;
    	kwg-ont:sfContains ?subLoc ;
    	kwg-ont:sfWithin ?superLoc ;
    	spatial:connectedTo ?s2 .
    
    FILTER(STRSTARTS(STR(?s2), STR(kwgr:s2)))
}
GROUP BY ?loc 
ORDER BY ?loc
LIMIT 10
graph TD
What is the Soil Organic Carbon (SOC) stock for each layer in experimental unit NDMAH3_T on 2008-04-04? Include Experimental Unit ID, Treatment ID, Date of Values, number the values used to calculate SOC stock, and the SOC stock value.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>  
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
SELECT ?expUnitId ?treatmentId ?date (xsd:integer(?upperDepth) AS ?UpperDepth) (xsd:integer(?lowerDepth) AS ?LowerDepth) (xsd:decimal(?soc) AS ?SOC) (xsd:decimal(?bulkDensity) AS ?BulkDensity) (xsd:decimal(?deltaDepth) AS ?DeltaDepth) ?SOCstock     
WHERE {     
    BIND("1998-04-20"^^xsd:date AS ?date)  
    BIND("GAJPCSR1_F1H2" AS ?treatmentId)  


    ?expUnit a sockg:ExperimentalUnit ;
        dcterms:identifier ?expUnitId ;
        kwg-ont:sfWithin ?spatial_data .


    # Make sure it is a field, not site ID
    FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) 
    ?spatial_data dcterms:identifier ?fieldId .        




    # Gather CHEM samples
    ?soilChem a sockg:SoilChemicalSample ;
        sockg:usesTreatment ?treatment ;
        sockg:lowerDepth ?LDepth ;
        sockg:upperDepth ?UDepth ;
        sockg:hasMeasurement ?meas ;
        sockg:fromUnit ?expUnit ;
        dcterms:date ?date .
    ?treatment dcterms:identifier ?treatmentId .


    ?LDepth qudt:numericValue ?lowerDepth .
    ?UDepth qudt:numericValue ?upperDepth ;
        qudt:hasUnit ?depthUnit .
    ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
        qudt:quantityValue ?result .
    ?result qudt:numericValue ?soc ;
        qudt:hasUnit ?socUnit .
    FILTER (?soc != 0)




    # ===================
    # Gather PHYS samples
    ?physSample a sockg:SoilPhysicalSample ;
        sockg:fromUnit ?expUnit ;
        sockg:usesTreatment ?treatment ;
        sockg:lowerDepth ?physLDepth ;
        sockg:hasMeasurement ?physMeasurement ;
        dcterms:date ?date .
    # To keep it simple, assume phys and chem samples have same layer depths
    ?physLDepth qudt:numericValue ?physLowerDepth .
    FILTER (?physLowerDepth = ?lowerDepth)
    ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
        qudt:quantityValue ?physResult .
    ?physResult qudt:numericValue ?bulkDensity ;
        qudt:hasUnit ?bulkDensityUnit .




    BIND(?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100 AS ?SOCstock) 
    BIND((?lowerDepth - ?upperDepth) AS ?deltaDepth)


}
ORDER BY ?LowerDepth
graph TD
What is the SOC stock, based on treatment Id, and what are the values used to find the SOC stock for each instance for GAJPCSR1_F1H2 on 1998-04-20?
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>  
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
SELECT ?expUnitId ?treatmentId ?date (xsd:integer(?upperDepth) AS ?UpperDepth) (xsd:integer(?lowerDepth) AS ?LowerDepth) (xsd:decimal(?soc) AS ?SOC) (xsd:decimal(?bulkDensity) AS ?BulkDensity) (xsd:decimal(?deltaDepth) AS ?DeltaDepth) ?SOCstock     
WHERE {     
    BIND("1998-04-20"^^xsd:date AS ?date)  
    BIND("GAJPCSR1_F1H2" AS ?treatmentId)  


    ?expUnit a sockg:ExperimentalUnit ;
             dcterms:identifier ?expUnitId ;
             kwg-ont:sfWithin ?spatial_data .


    # Make sure it is a field, not site ID
    FILTER(STRSTARTS(STR(?spatial_data), STR(ind:Location))) 
    ?spatial_data dcterms:identifier ?fieldId .        




    # Gather CHEM samples
    ?soilChem a sockg:SoilChemicalSample ;
              sockg:usesTreatment ?treatment ;
              sockg:lowerDepth ?LDepth ;
              sockg:upperDepth ?UDepth ;
              sockg:hasMeasurement ?meas ;
              sockg:fromUnit ?expUnit ;
              dcterms:date ?date .
    ?treatment dcterms:identifier ?treatmentId .


    ?LDepth qudt:numericValue ?lowerDepth .
    ?UDepth qudt:numericValue ?upperDepth ;
            qudt:hasUnit ?depthUnit .
    ?meas sockg:of ind:Parameter.MeasSoilChem.17 ; # IRI of osc_gc_kg
          qudt:quantityValue ?result .
    ?result qudt:numericValue ?soc ;
            qudt:hasUnit ?socUnit .
    FILTER (?soc != 0)




    # ===================
    # Gather PHYS samples
    ?physSample a sockg:SoilPhysicalSample ;
                sockg:fromUnit ?expUnit ;
                sockg:usesTreatment ?treatment ;
                sockg:lowerDepth ?physLDepth ;
                sockg:hasMeasurement ?physMeasurement ;
                dcterms:date ?date .
    # To keep it simple, assume phys and chem samples have same layer depths
    ?physLDepth qudt:numericValue ?physLowerDepth .
    FILTER (?physLowerDepth = ?lowerDepth)
    ?physMeasurement sockg:of ind:Parameter.MeasSoilPhys.12 ; # IRI of bulk_density_g_cm3
                     qudt:quantityValue ?physResult .
    ?physResult qudt:numericValue ?bulkDensity ;
                qudt:hasUnit ?bulkDensityUnit .




    BIND(?soc * ?bulkDensity * (?lowerDepth - ?upperDepth) * 100 AS ?SOCstock) 
    BIND((?lowerDepth - ?upperDepth) AS ?deltaDepth)


}
ORDER BY ?LowerDepth
graph TD
Get all Soil Biological Samples and their corresponding attributes (date, lower and upper depth, expUnit, etc.)
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT DISTINCT ?expUnit ?date ?upperDepth ?lowerDepth ?label WHERE {
    ?b a sockg:SoilBiologicalSample ;
        sockg:fromUnit ?e ;
        sockg:lowerDepth ?ld ;
        sockg:upperDepth ?ud ;
        dcterms:date ?date .

    ?e dcterms:identifier ?expUnit .
    ?ld qudt:numericValue ?lowerDepth .
    ?ud qudt:numericValue ?upperDepth .
}
ORDER BY ?expUnit ?date ?label
LIMIT 5
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?b")
  v2("?date"):::projected 
  v5("?e")
  v1("?expUnit"):::projected 
  v3("?label"):::projected 
  v6("?ld")
  v8("?lowerDepth"):::projected 
  v7("?ud")
  v9("?upperDepth"):::projected 
  c2([sockg:SoilBiologicalSample]):::iri 
  v4 --"a"-->  c2
  v4 --"sockg:fromUnit"-->  v5
  v4 --"sockg:lowerDepth"-->  v6
  v4 --"sockg:upperDepth"-->  v7
  v4 --"dct:date"-->  v2
  v5 --"dct:identifier"-->  v1
  v6 --"qudt:numericValue"-->  v8
  v7 --"qudt:numericValue"-->  v9
Which samples have a carbon concentration greater than or equal to 475 gC/kg? What additional information about these samples might help explain why their carbon concentration is so high? Include Unique ID, Treatment ID, Crop(s) used at Field, Plant Fraction use, Carbon Concentration value in your response.
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>
PREFIX kwg-ont: <http://stko-kwg.geog.ucsb.edu/lod/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ind: <https://idir.uta.edu/sockg-ontology/individuals/>
PREFIX dcterms: <http://purl.org/dc/terms/>


PREFIX ns1: <http://qudt.org/schema/qudt/>
SELECT DISTINCT ?treatmentId ?date ?crop ?plantFraction ?carbon_concentration ?Unit 
WHERE {
    ?b a sockg:BiomassMineral ;
        dcterms:date ?date ;
        sockg:usesTreatment ?t ;
        sockg:hasMeasurement ?meas ;
        sockg:hasPlantFraction ?pf ;
        sockg:hasCrop ?c .
    
    # get human readable labels
    ?t dcterms:identifier ?treatmentId .
        ?pf rdfs:label ?plantFraction .
    ?c rdfs:label ?crop .
    
    # get carbon concentration vals and unit
    ?meas sockg:of ind:Parameter.MeasBiomassMinAn.9 ;
        ns1:quantityValue ?vals .
    ?vals ns1:numericValue ?carbon_concentration ;
        ns1:hasUnit ?Unit
    
    FILTER(?carbon_concentration >= 475.0)
       
}
ORDER BY ?date
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v12("?Unit"):::projected 
  v3("?b")
  v7("?c")
  v2("?carbon_concentration"):::projected 
  v10("?crop"):::projected 
  v1("?date"):::projected 
  v5("?meas")
  v6("?pf")
  v9("?plantFraction"):::projected 
  v4("?t")
  v8("?treatmentId"):::projected 
  v11("?vals")
  c12([https://idir.uta.edu/sockg-ontology/individuals/Parameter.MeasBiomassMinAn.9]):::iri 
  c3([sockg:BiomassMineral]):::iri 
  f0[["?carbon_concentration >= '475.0^^xsd:decimal'"]]
  f0 --> v2
  v3 --"a"-->  c3
  v3 --"dct:date"-->  v1
  v3 --"sockg:usesTreatment"-->  v4
  v3 --"sockg:hasMeasurement"-->  v5
  v3 --"sockg:hasPlantFraction"-->  v6
  v3 --"sockg:hasCrop"-->  v7
  v4 --"dct:identifier"-->  v8
  v6 --"rdfs:label"-->  v9
  v7 --"rdfs:label"-->  v10
  v5 --"sockg:of"-->  c12
  v5 --"qudt:quantityValue"-->  v11
  v11 --"qudt:numericValue"-->  v2
  v11 --"qudt:hasUnit"-->  v12
Get all Water Data Samples and their corresponding attributes (date, expUnit, treatmentId, Runoff, growth stage, etc.)
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sockg: <https://idir.uta.edu/sockg-ontology#>

SELECT DISTINCT ?expUnit ?treatment ?date ?SurfOrLeach ?LossOrDep ?label ?Value ?Unit WHERE {
    ?b a sockg:WaterQualityArea ;
    	sockg:hasMeasurement ?m ;
	    sockg:fromUnit ?e ;
		sockg:usesTreatment ?t ;
    	sockg:hasSurfaceOrLeaching ?sl ;
		sockg:hasLossesOrDeposition ?ld ;
    	dcterms:date ?date .
    
    ?e dcterms:identifier ?expUnit .
    ?sl rdfs:label ?SurfOrLeach .
    ?ld rdfs:label ?LossOrDep .
    ?t dcterms:identifier ?treatment .

    
    ?m sockg:of ?param ;
        qudt:quantityValue ?v .
    ?param a sockg:Parameter ;
            rdfs:label ?label .
    ?v qudt:numericValue ?Value ;
        qudt:hasUnit ?Unit .
}
ORDER BY ?expUnit ?date ?label
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v11("?LossOrDep"):::projected 
  v10("?SurfOrLeach"):::projected 
  v16("?Unit"):::projected 
  v15("?Value"):::projected 
  v4("?b")
  v2("?date"):::projected 
  v6("?e")
  v1("?expUnit"):::projected 
  v3("?label"):::projected 
  v9("?ld")
  v5("?m")
  v13("?param")
  v8("?sl")
  v7("?t")
  v12("?treatment"):::projected 
  v14("?v")
  c13([sockg:Parameter]):::iri 
  c2([sockg:WaterQualityArea]):::iri 
  v4 --"a"-->  c2
  v4 --"sockg:hasMeasurement"-->  v5
  v4 --"sockg:fromUnit"-->  v6
  v4 --"sockg:usesTreatment"-->  v7
  v4 --"sockg:hasSurfaceOrLeaching"-->  v8
  v4 --"sockg:hasLossesOrDeposition"-->  v9
  v4 --"dct:date"-->  v2
  v6 --"dct:identifier"-->  v1
  v8 --"rdfs:label"-->  v10
  v9 --"rdfs:label"-->  v11
  v7 --"dct:identifier"-->  v12
  v5 --"sockg:of"-->  v13
  v5 --"qudt:quantityValue"-->  v14
  v13 --"a"-->  c13
  v13 --"rdfs:label"-->  v3
  v14 --"qudt:numericValue"-->  v15
  v14 --"qudt:hasUnit"-->  v16
Who worked on the agcros dataset, what was their role, and what field did they work on?
PREFIX schema: <https://schema.org/>
PREFIX dcterms: <http://purl.org/dc/terms/>


SELECT DISTINCT ?name ?role (GROUP_CONCAT(?ename; SEPARATOR=", ") AS ?fieldName)
WHERE {
    ?e a schema:Person ;
       schema:givenName ?fname ;
       schema:additionalName ?mname ;
       schema:familyName ?lname ;
       schema:workLocation ?l ;
       schema:role ?role .


    ?l dcterms:identifier ?ename .
    
    BIND(IF(CONTAINS(STR(?mname), "."),
            CONCAT(STR(?fname), " ", STR(?mname), " ", STR(?lname)), 
            CONCAT(STR(?fname), " ", STR(?mname), ". ", STR(?lname)) 
        ) AS ?name)
}
GROUP BY ?name ?role
ORDER BY ?name
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?e")
  v8("?ename"):::projected 
  v9("?fieldName")
  v3("?fname")
  v6("?l")
  v5("?lname")
  v4("?mname")
  v9("?name"):::projected 
  v7("?role"):::projected 
  c2([schema:Person]):::iri 
  v2 --"a"-->  c2
  v2 --"schema:givenName"-->  v3
  v2 --"schema:additionalName"-->  v4
  v2 --"schema:familyName"-->  v5
  v2 --"schema:workLocation"-->  v6
  v2 --"schema:role"-->  v7
  v6 --"dct:identifier"-->  v8
  bind0[/"if(contains(str(?mname),'.'),concat(str(?fname),' ',str(?mname),' ',str(?lname)),concat(str(?fname),' ',str(?mname),'. ',str(?lname)))"/]
  v4 --o bind0
  v3 --o bind0
  v5 --o bind0
  bind0 --as--o v9
  bind2[/"?ename"/]
  v8 --o bind2
  bind2 --as--o v9
SPARQL Endpoint https://frink.apps.renci.org/sockg/sparql
Triple Pattern Fragments https://frink.apps.renci.org/ldf/sockg
ClassEntities
PropertyTriples